From patchwork Thu Feb 11 09:56:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Jenkins X-Patchwork-Id: 78669 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1B9vbIv015804 for ; Thu, 11 Feb 2010 09:57:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753237Ab0BKJ4w (ORCPT ); Thu, 11 Feb 2010 04:56:52 -0500 Received: from mail-yx0-f193.google.com ([209.85.210.193]:63529 "EHLO mail-yx0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752972Ab0BKJ4v (ORCPT ); Thu, 11 Feb 2010 04:56:51 -0500 Received: by yxe31 with SMTP id 31so946342yxe.21 for ; Thu, 11 Feb 2010 01:56:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=S1xNzLrERR58j7tzbcWQIu/PlsfchDehIy1POK5RrzQ=; b=qwigkvvo+mw3K4qtqEYPPkA+fv/xcy6XTLfGU4yIXDRZnrPThYr9KnvVVlvZS0+Pbw uj7lZ2UhW4UDZRqSnegQWf+Q4aSe+nlD9xmtEfo8dSn/WdDUCG13EK9xqzkpXHtsSVVA KTl9ZmMO6aVlvaf9fmMWqyErTbb+VE6ddD2UA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=iiT147KwBPj3L/rgz7vKXtxOD5kaTy5vEiI6a1OPM/4Cw/Od8j/WSdBLvav7y2Czvp 5/uCqd99Ctz8uBhUDXTMcqNGoho1PAu9dYDzHI0hTIckBmzecAtjgerHwjflitb/os1R 0POO4WlTvIosY7C8bGTQJg6NdPvTY00Wy5sWc= Received: by 10.151.60.18 with SMTP id n18mr4285482ybk.31.1265882209263; Thu, 11 Feb 2010 01:56:49 -0800 (PST) Received: from ?192.168.2.3? (C-59-101-225-152.bur.connect.net.au [59.101.225.152]) by mx.google.com with ESMTPS id 20sm830580yxe.56.2010.02.11.01.56.44 (version=SSLv3 cipher=RC4-MD5); Thu, 11 Feb 2010 01:56:48 -0800 (PST) Subject: [PATCH] drivers: acpi: fan.c move a dereference below the NULL test From: Darren Jenkins To: Len Brown Cc: Zhang Rui , Thomas Renninger , Alexey Dobriyan , Matthew Garrett , linux ACPI , Linux Kernel Mailing List , Kernel Janitors Date: Thu, 11 Feb 2010 20:56:42 +1100 Message-ID: <1265882202.27789.0.camel@ICE-BOX> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 11 Feb 2010 09:57:37 +0000 (UTC) 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);