From: Zhang Rui <rui.zhang@intel.com>
To: Len Brown <lenb@kernel.org>
Cc: Darren Jenkins <darrenrjenkins@gmail.com>,
Thomas Renninger <trenn@suse.de>,
Alexey Dobriyan <adobriyan@gmail.com>,
Matthew Garrett <mjg@redhat.com>,
linux ACPI <linux-acpi@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Kernel Janitors <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] drivers: acpi: fan.c move a dereference below the NULL test
Date: Mon, 22 Feb 2010 09:37:03 +0800 [thread overview]
Message-ID: <1266802623.2608.1471.camel@rzhang1-desktop> (raw)
In-Reply-To: <alpine.LFD.2.00.1002190026070.17638@localhost.localdomain>
On Fri, 2010-02-19 at 13:27 +0800, Len Brown wrote:
> I think think this is a run-time check for a programming error,
> and the current fashion is to delete the check and take a fault
> if this happens so the caller can be fixed.
>
I agree.
> There are a couple of checks like this in fan.c --
> perhaps Rui can clean them up when he comes back next week.
>
I'll send the cleanup patch later.
thanks,
rui
> thanks,
> Len Brown, Intel Open Source Technology Center
>
> On Thu, 11 Feb 2010, Darren Jenkins wrote:
>
> > 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
> >
> >
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
prev parent reply other threads:[~2010-02-22 1:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-11 9:56 [PATCH] drivers: acpi: fan.c move a dereference below the NULL test Darren Jenkins
2010-02-19 5:27 ` Len Brown
2010-02-19 11:02 ` Thomas Renninger
2010-02-22 1:37 ` Zhang Rui [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1266802623.2608.1471.camel@rzhang1-desktop \
--to=rui.zhang@intel.com \
--cc=adobriyan@gmail.com \
--cc=darrenrjenkins@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=trenn@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox