From patchwork Tue Jul 28 15:56:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 37829 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6SFui2i028552 for ; Tue, 28 Jul 2009 15:56:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754667AbZG1P4m (ORCPT ); Tue, 28 Jul 2009 11:56:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754666AbZG1P4m (ORCPT ); Tue, 28 Jul 2009 11:56:42 -0400 Received: from mgw1.diku.dk ([130.225.96.91]:35764 "EHLO mgw1.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754555AbZG1P4l (ORCPT ); Tue, 28 Jul 2009 11:56:41 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw1.diku.dk (Postfix) with ESMTP id 7A7EB52C37A; Tue, 28 Jul 2009 17:56:41 +0200 (CEST) X-Virus-Scanned: amavisd-new at diku.dk Received: from mgw1.diku.dk ([127.0.0.1]) by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YbOqzHiWLQ4f; Tue, 28 Jul 2009 17:56:40 +0200 (CEST) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw1.diku.dk (Postfix) with ESMTP id DA19752C333; Tue, 28 Jul 2009 17:56:35 +0200 (CEST) Received: from ask.diku.dk (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id EDFE06DFD05; Tue, 28 Jul 2009 17:55:50 +0200 (CEST) Received: by ask.diku.dk (Postfix, from userid 3767) id C5297154D2F; Tue, 28 Jul 2009 17:56:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ask.diku.dk (Postfix) with ESMTP id C3B7A1549A9; Tue, 28 Jul 2009 17:56:35 +0200 (CEST) Date: Tue, 28 Jul 2009 17:56:35 +0200 (CEST) From: Julia Lawall To: rui.zhang@intel.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 9/9] drivers/acpi: correct error-handling code Message-ID: MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Julia Lawall backlight_device_register may return an ERR_PTR value rather than a valid pointer. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ identifier fld,fld1; expression x,E; @@ x = backlight_device_register(...) ... when != x = E when != &x when != x->fld1 ( ((IS_ERR(x))||...) | * x->fld ) // Signed-off-by: Julia Lawall --- drivers/acpi/video.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 8851315..29788db 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -982,6 +982,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) sprintf(name, "acpi_video%d", count++); device->backlight = backlight_device_register(name, NULL, device, &acpi_backlight_ops); + if (IS_ERR(device->backlight)) + return; device->backlight->props.max_brightness = device->brightness->count-3; kfree(name);