Linux ACPI
 help / color / mirror / Atom feed
* [PATCH 9/9] drivers/acpi: correct error-handling code
@ 2009-07-28 15:56 Julia Lawall
  2009-07-29  0:53 ` Zhang Rui
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2009-07-28 15:56 UTC (permalink / raw)
  To: rui.zhang, linux-acpi, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

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/)

// <smpl>
@@
identifier fld,fld1;
expression x,E;
@@

 x = backlight_device_register(...)
  ... when != x = E
      when != &x
      when != x->fld1
(
  ((IS_ERR(x))||...)
|
*  x->fld
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/acpi/video.c                |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

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);
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-30  6:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28 15:56 [PATCH 9/9] drivers/acpi: correct error-handling code Julia Lawall
2009-07-29  0:53 ` Zhang Rui
2009-07-29  2:20   ` Julia Lawall
2009-12-30  6:51   ` Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox