All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Jenkins <darrenrjenkins@gmail.com>
To: Thomas Renninger <trenn@suse.de>
Cc: Julia Lawall <julia@diku.dk>, Len Brown <lenb@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	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/processor_thermal.c
Date: Fri, 12 Feb 2010 00:03:52 +1100	[thread overview]
Message-ID: <1265893432.27789.14.camel@ICE-BOX> (raw)


On Thu, Feb 11, 2010 at 10:04 PM, Thomas Renninger <trenn@suse.de>
wrote:
> I expect also Darren has to rebase his fixes on top of this
> one then.

In case Len decides to go this way, here are the two patches rebased on top of this change 
and combined into one patch.

[PATCH] drivers/acpi/ fix use before NULL checking 

Fix some use before NULL checks by re-ordering of code in drivers/acpi

Coverity CID: 2752 2751 2750 2758


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

diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 1290c25..278cebd 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 = device->driver_data;
+	struct thermal_cooling_device *cdev;
+
+	if (!device)
+		return -EINVAL;
+
+	cdev = device->driver_data;
 
-	if (!device || !cdev)
+	if (!cdev)
 		return -EINVAL;
 
 	acpi_fan_remove_fs(device);
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index cd18c98..3c9f8ac 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 = device->driver_data;
+	struct acpi_processor *pr;
 
-	if (!device || !pr)
+	if (!device)
+		return -EINVAL;
+
+	pr = device->driver_data;
+
+	if (!pr)
 		return -EINVAL;
 
 	*state = acpi_processor_max_state(pr);
@@ -393,9 +398,14 @@ processor_get_cur_state(struct thermal_cooling_device *cdev,
 			unsigned long *cur_state)
 {
 	struct acpi_device *device = cdev->devdata;
-	struct acpi_processor *pr = device->driver_data;
+	struct acpi_processor *pr;
+
+	if (!device)
+		return -EINVAL;
 
-	if (!device || !pr)
+	pr = device->driver_data;
+
+	if (!pr)
 		return -EINVAL;
 
 	*cur_state = cpufreq_get_cur_state(pr->id);
@@ -409,18 +419,20 @@ processor_set_cur_state(struct thermal_cooling_device *cdev,
 			unsigned long state)
 {
 	struct acpi_device *device = cdev->devdata;
-	struct acpi_processor *pr = device->driver_data;
+	struct acpi_processor *pr;
 	int result = 0;
 	int max_pstate;
 
-	if (!device || !pr)
+	if (!device)
 		return -EINVAL;
 
-	max_pstate = cpufreq_get_max_state(pr->id);
+	pr = device->driver_data;
 
-	if (state > acpi_processor_max_state(pr))
+	if (!pr || state > acpi_processor_max_state(pr))
 		return -EINVAL;
 
+	max_pstate = cpufreq_get_max_state(pr->id);
+
 	if (state <= max_pstate) {
 		if (pr->flags.throttling && pr->throttling.state)
 			result = acpi_processor_set_throttling(pr, 0, false);
-- 
1.6.3.3

 




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


On Thu, Feb 11, 2010 at 10:04 PM, Thomas Renninger <trenn@suse.de>
wrote:
> I expect also Darren has to rebase his fixes on top of this
> one then.

In case Len decides to go this way, here are the two patches rebased on top of this change 
and combined into one patch.

[PATCH] drivers/acpi/ fix use before NULL checking 

Fix some use before NULL checks by re-ordering of code in drivers/acpi

Coverity CID: 2752 2751 2750 2758


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

diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 1290c25..278cebd 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 = device->driver_data;
+	struct thermal_cooling_device *cdev;
+
+	if (!device)
+		return -EINVAL;
+
+	cdev = device->driver_data;
 
-	if (!device || !cdev)
+	if (!cdev)
 		return -EINVAL;
 
 	acpi_fan_remove_fs(device);
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index cd18c98..3c9f8ac 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 = device->driver_data;
+	struct acpi_processor *pr;
 
-	if (!device || !pr)
+	if (!device)
+		return -EINVAL;
+
+	pr = device->driver_data;
+
+	if (!pr)
 		return -EINVAL;
 
 	*state = acpi_processor_max_state(pr);
@@ -393,9 +398,14 @@ processor_get_cur_state(struct thermal_cooling_device *cdev,
 			unsigned long *cur_state)
 {
 	struct acpi_device *device = cdev->devdata;
-	struct acpi_processor *pr = device->driver_data;
+	struct acpi_processor *pr;
+
+	if (!device)
+		return -EINVAL;
 
-	if (!device || !pr)
+	pr = device->driver_data;
+
+	if (!pr)
 		return -EINVAL;
 
 	*cur_state = cpufreq_get_cur_state(pr->id);
@@ -409,18 +419,20 @@ processor_set_cur_state(struct thermal_cooling_device *cdev,
 			unsigned long state)
 {
 	struct acpi_device *device = cdev->devdata;
-	struct acpi_processor *pr = device->driver_data;
+	struct acpi_processor *pr;
 	int result = 0;
 	int max_pstate;
 
-	if (!device || !pr)
+	if (!device)
 		return -EINVAL;
 
-	max_pstate = cpufreq_get_max_state(pr->id);
+	pr = device->driver_data;
 
-	if (state > acpi_processor_max_state(pr))
+	if (!pr || state > acpi_processor_max_state(pr))
 		return -EINVAL;
 
+	max_pstate = cpufreq_get_max_state(pr->id);
+
 	if (state <= max_pstate) {
 		if (pr->flags.throttling && pr->throttling.state)
 			result = acpi_processor_set_throttling(pr, 0, false);
-- 
1.6.3.3

 




             reply	other threads:[~2010-02-11 13:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11 13:03 Darren Jenkins [this message]
2010-02-11 13:03 ` [PATCH] drivers/acpi/processor_thermal.c Darren Jenkins
  -- strict thread matches above, loose matches on Subject: below --
2010-02-11  9:56 Darren Jenkins
2010-02-11  9:56 ` Darren Jenkins
2010-02-11 10:24 ` Thomas Renninger
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

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=1265893432.27789.14.camel@ICE-BOX \
    --to=darrenrjenkins@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hsweeten@visionengravers.com \
    --cc=julia@diku.dk \
    --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=rui.zhang@intel.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 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.