All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.de>
To: Darren Jenkins <darrenrjenkins@gmail.com>
Cc: Len Brown <lenb@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	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/processor_thermal.c
Date: Thu, 11 Feb 2010 11:24:50 +0100	[thread overview]
Message-ID: <201002111124.51070.trenn@suse.de> (raw)
In-Reply-To: <1265882211.27789.1.camel@ICE-BOX>

Eh, 

what is this for?:
static inline void *acpi_driver_data(struct acpi_device *d)
{
        return d->driver_data;
}

On Thursday 11 February 2010 10:56:51 Darren Jenkins wrote:
> There are a few places where a pointer is dereferenced with acpi_driver_data()
> before a NULL test. This re-orders the code to fix these issues.
> 
> Coverity CID: 2752 2751 2750
> 
> Signed-off-by: Darren Jenkins <darrenrjenkins@gmail.com>
> ---
>  drivers/acpi/processor_thermal.c |   28 ++++++++++++++++++++--------
>  1 files changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
> index 6deafb4..ec33554 100644
> --- a/drivers/acpi/processor_thermal.c
> +++ b/drivers/acpi/processor_thermal.c
> @@ -379,9 +379,14 @@ processor_get_max_state(struct thermal_cooling_device *cdev,
>  			unsigned long *state)
>  {
>  	struct acpi_device *device = cdev->devdata;
> -	struct acpi_processor *pr = acpi_driver_data(device);
> +	struct acpi_processor *pr;
>  
> -	if (!device || !pr)
> +	if (!device)
> +		return -EINVAL;
> +
> +	pr = acpi_driver_data(device);
Better use (here and at other places):
device->driver_data
instead of
acpi_driver_data(device)

if you touch this anyway.
Then such bugs like the one you address here, don't happen
anymore in the future.
If you have some more time you might want to revert all the
other instances and revert the acpi_driver_data declaration
in include/acpi/acpi_bus.h

Thanks,

       Thomas

WARNING: multiple messages have this Message-ID (diff)
From: Thomas Renninger <trenn@suse.de>
To: Darren Jenkins <darrenrjenkins@gmail.com>
Cc: Len Brown <lenb@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	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/processor_thermal.c
Date: Thu, 11 Feb 2010 10:24:50 +0000	[thread overview]
Message-ID: <201002111124.51070.trenn@suse.de> (raw)
In-Reply-To: <1265882211.27789.1.camel@ICE-BOX>

Eh, 

what is this for?:
static inline void *acpi_driver_data(struct acpi_device *d)
{
        return d->driver_data;
}

On Thursday 11 February 2010 10:56:51 Darren Jenkins wrote:
> There are a few places where a pointer is dereferenced with acpi_driver_data()
> before a NULL test. This re-orders the code to fix these issues.
> 
> Coverity CID: 2752 2751 2750
> 
> Signed-off-by: Darren Jenkins <darrenrjenkins@gmail.com>
> ---
>  drivers/acpi/processor_thermal.c |   28 ++++++++++++++++++++--------
>  1 files changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
> index 6deafb4..ec33554 100644
> --- a/drivers/acpi/processor_thermal.c
> +++ b/drivers/acpi/processor_thermal.c
> @@ -379,9 +379,14 @@ processor_get_max_state(struct thermal_cooling_device *cdev,
>  			unsigned long *state)
>  {
>  	struct acpi_device *device = cdev->devdata;
> -	struct acpi_processor *pr = acpi_driver_data(device);
> +	struct acpi_processor *pr;
>  
> -	if (!device || !pr)
> +	if (!device)
> +		return -EINVAL;
> +
> +	pr = acpi_driver_data(device);
Better use (here and at other places):
device->driver_data
instead of
acpi_driver_data(device)

if you touch this anyway.
Then such bugs like the one you address here, don't happen
anymore in the future.
If you have some more time you might want to revert all the
other instances and revert the acpi_driver_data declaration
in include/acpi/acpi_bus.h

Thanks,

       Thomas

  reply	other threads:[~2010-02-11 10:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11  9:56 [PATCH] drivers/acpi/processor_thermal.c Darren Jenkins
2010-02-11  9:56 ` Darren Jenkins
2010-02-11 10:24 ` Thomas Renninger [this message]
2010-02-11 10:24   ` Thomas Renninger
2010-02-11 10:52   ` Julia Lawall
2010-02-11 10:52     ` Julia Lawall
2010-02-11 11:04     ` Thomas Renninger
2010-02-11 11:04       ` Thomas Renninger
2010-02-11 13:03 Darren Jenkins
2010-02-11 13:03 ` Darren Jenkins

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=201002111124.51070.trenn@suse.de \
    --to=trenn@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=darrenrjenkins@gmail.com \
    --cc=hsweeten@visionengravers.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    /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 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.