lkml.org 
[lkml]   [2010]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] drivers: acpi: fan.c move a dereference below the NULL test
From
Date
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





\
 
 \ /
  Last update: 2010-02-11 10:59    [W:0.072 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site