All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: acpi: fan.c move a dereference below the NULL test
@ 2010-02-11  9:56 ` Darren Jenkins
  0 siblings, 0 replies; 8+ messages in thread
From: Darren Jenkins @ 2010-02-11  9:56 UTC (permalink / raw)
  To: Len Brown
  Cc: Zhang Rui, Thomas Renninger, Alexey Dobriyan, Matthew Garrett,
	linux ACPI, Linux Kernel Mailing List, Kernel Janitors

In acpi_fan_remove() device is being dereferenced before the NULL test.
This reorders the code to ensure it is checked for NULL first.

Coverity CID: 2758

Signed-off-by: Darren Jenkins <darrenrjenkins@gmail.com>
---
 drivers/acpi/fan.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index acf2ab2..dc39640 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -298,9 +298,14 @@ static int acpi_fan_add(struct acpi_device *device)
 
 static int acpi_fan_remove(struct acpi_device *device, int type)
 {
-	struct thermal_cooling_device *cdev = acpi_driver_data(device);
+	struct thermal_cooling_device *cdev;
+
+	if (!device)
+		return -EINVAL;
+
+	cdev = acpi_driver_data(device);
 
-	if (!device || !cdev)
+	if (!cdev)
 		return -EINVAL;
 
 	acpi_fan_remove_fs(device);
-- 
1.6.3.3





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

end of thread, other threads:[~2010-02-22  1:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-11  9:56 [PATCH] drivers: acpi: fan.c move a dereference below the NULL test Darren Jenkins
2010-02-11  9:56 ` Darren Jenkins
2010-02-19  5:27 ` Len Brown
2010-02-19  5:27   ` Len Brown
2010-02-19 11:02   ` Thomas Renninger
2010-02-19 11:02     ` Thomas Renninger
2010-02-22  1:37   ` [PATCH] drivers: acpi: fan.c move a dereference below the NULL Zhang Rui
2010-02-22  1:37     ` [PATCH] drivers: acpi: fan.c move a dereference below the NULL test Zhang Rui

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.