linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bug-fix]:2.6.25-rc0 Generic thermal management [Patch 1/2]: validating input parameters
@ 2008-02-11 10:27 Thomas, Sujith
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas, Sujith @ 2008-02-11 10:27 UTC (permalink / raw)
  To: Len Brown, Ingo Molnar
  Cc: linux-kernel, linux-acpi, linux-pm, Andrew Morton, Linus Torvalds

From: Thomas Sujith <sujith.thomas@intel.com>

Added sanity checks for interface functions in thermal with
other modules such as fan, processor, video etc..

Signed-off-by: Thomas Sujith <sujith.thomas@intel.com>
---
drivers/thermal/thermal.c |   69
+++++++++++++++++++++++++++++-----------------
 1 files changed, 44 insertions(+), 25 deletions(-)

Index: linux-2.6.24-rc3/drivers/thermal/thermal.c
===================================================================
--- linux-2.6.24-rc3.orig/drivers/thermal/thermal.c
+++ linux-2.6.24-rc3/drivers/thermal/thermal.c
@@ -301,13 +301,27 @@ int thermal_zone_bind_cooling_device(str
 {
 	struct thermal_cooling_device_instance *dev;
 	struct thermal_cooling_device_instance *pos;
+	struct thermal_zone_device *pos1;
+	struct thermal_cooling_device *pos2;
 	int result;
 
+	if (!tz || !cdev)
+		return -EINVAL;
+
 	if (trip >= tz->trips ||
 	    (trip < 0 && trip != THERMAL_TRIPS_NONE))
 		return -EINVAL;
 
-	if (!tz || !cdev)
+	list_for_each_entry(pos1, &thermal_tz_list, node) {
+		if (pos1 == tz)
+			break;
+	}
+	list_for_each_entry(pos2, &thermal_cdev_list, node) {
+		if (pos2 == cdev)
+			break;
+	}
+
+	if (tz != pos1 || cdev != pos2)
 		return -EINVAL;
 
 	dev =
@@ -373,6 +387,9 @@ int thermal_zone_unbind_cooling_device(s
 {
 	struct thermal_cooling_device_instance *pos, *next;
 
+	if (!tz || !cdev)
+		return -EINVAL;
+
 	mutex_lock(&tz->lock);
 	list_for_each_entry_safe(pos, next, &tz->cooling_devices, node)
{
 		if (pos->tz == tz && pos->trip == trip
@@ -427,21 +444,24 @@ struct thermal_cooling_device *thermal_c
 	struct thermal_zone_device *pos;
 	int result;
 
+	if (!type)
+		return ERR_PTR(-EINVAL);
+
 	if (strlen(type) >= THERMAL_NAME_LENGTH)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	if (!ops || !ops->get_max_state || !ops->get_cur_state ||
 		!ops->set_cur_state)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	cdev = kzalloc(sizeof(struct thermal_cooling_device),
GFP_KERNEL);
 	if (!cdev)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	result = get_idr(&thermal_cdev_idr, &thermal_idr_lock,
&cdev->id);
 	if (result) {
 		kfree(cdev);
-		return NULL;
+		return ERR_PTR(result);
 	}
 
 	strcpy(cdev->type, type);
@@ -453,16 +473,14 @@ struct thermal_cooling_device *thermal_c
 	if (result) {
 		release_idr(&thermal_cdev_idr, &thermal_idr_lock,
cdev->id);
 		kfree(cdev);
-		return NULL;
+		return 	ERR_PTR(result);
 	}
 
 	/* sys I/F */
-	if (type) {
-		result = device_create_file(&cdev->device,
-					    &dev_attr_cdev_type);
-		if (result)
-			goto unregister;
-	}
+	result = device_create_file(&cdev->device,
+				    &dev_attr_cdev_type);
+	if (result)
+		goto unregister;
 
 	result = device_create_file(&cdev->device, &dev_attr_max_state);
 	if (result)
@@ -490,7 +508,7 @@ struct thermal_cooling_device *thermal_c
       unregister:
 	release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id);
 	device_unregister(&cdev->device);
-	return NULL;
+	return ERR_PTR(result);
 }
 EXPORT_SYMBOL(thermal_cooling_device_register);
 
@@ -559,18 +577,21 @@ struct thermal_zone_device *thermal_zone
 	int result;
 	int count;
 
+	if (!type)
+		return ERR_PTR(-EINVAL);
+
 	if (strlen(type) >= THERMAL_NAME_LENGTH)
-		return NULL;
+		return  ERR_PTR(-EINVAL);
 
 	if (trips > THERMAL_MAX_TRIPS || trips < 0)
-		return NULL;
+		return  ERR_PTR(-EINVAL);
 
 	if (!ops || !ops->get_temp)
-		return NULL;
+		return  ERR_PTR(-EINVAL);
 
 	tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL);
 	if (!tz)
-		return NULL;
+		return  ERR_PTR(-ENOMEM);
 
 	INIT_LIST_HEAD(&tz->cooling_devices);
 	idr_init(&tz->idr);
@@ -578,7 +599,7 @@ struct thermal_zone_device *thermal_zone
 	result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id);
 	if (result) {
 		kfree(tz);
-		return NULL;
+		return  ERR_PTR(result);
 	}
 
 	strcpy(tz->type, type);
@@ -591,15 +612,13 @@ struct thermal_zone_device *thermal_zone
 	if (result) {
 		release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
 		kfree(tz);
-		return NULL;
+		return  ERR_PTR(result);
 	}
 
 	/* sys I/F */
-	if (type) {
-		result = device_create_file(&tz->device,
&dev_attr_type);
-		if (result)
-			goto unregister;
-	}
+	result = device_create_file(&tz->device, &dev_attr_type);
+	if (result)
+		goto unregister;
 
 	result = device_create_file(&tz->device, &dev_attr_temp);
 	if (result)
@@ -633,7 +652,7 @@ struct thermal_zone_device *thermal_zone
       unregister:
 	release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
 	device_unregister(&tz->device);
-	return NULL;
+	return ERR_PTR(result);
 }
 EXPORT_SYMBOL(thermal_zone_device_register);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bug-fix]:2.6.25-rc0 Generic thermal management [Patch 1/2]: validating input parameters
       [not found]       ` <05B550FD4BD2014E841D83547B62600802A6BA72@bgsmsx411.gar.corp.intel.com>
@ 2008-02-13 18:33         ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2008-02-13 18:33 UTC (permalink / raw)
  To: Thomas, Sujith; +Cc: linux-kernel, linux-acpi, mingo, torvalds, linux-pm

On Wed, 13 Feb 2008 16:33:10 +0530
"Thomas, Sujith" <sujith.thomas@intel.com> wrote:

> 	For time being I am attaching the patch and in the meanwhile
> I'll figure out
> a way to fix the wordwrap issues. This was what Len Brown also had
> recommended.

This patch has no changelog.  Please include the full and up-to-date
changelog with each iteration of a patch.

This patch doesn't apply.  My version of Linux has

	if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE))
		return -EINVAL;

whereas yours apparently has

  	if (trip >= tz->trips ||
  	    (trip < 0 && trip != THERMAL_TRIPS_NONE))
  		return -EINVAL;

(plus other changes).

Maybe you have some other patch which predeced this one.

You apparently didn't resend "[Bug-fix]:2.6.25-rc0 Generic thermal
management:ACPI [Patch 2/2]: buildfix for CONFIG_THERMAL=n" which was also
mangled.


So please just start again.  Resend all patches, against latest mainline,
with full changelogs and appropriate cc's, in an unmangled form.

Also it would be good if you could be a bit more conventional with the
patch titling.  For this one, 

Subject: [patch 1/2] Generic thermal management: validate input parameters

would suit.  Section 14 of Documentation/SubmittingPatches has some
explanation.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Bug-fix]:2.6.25-rc0 Generic thermal management [Patch 1/2]: validating input parameters
       [not found]     ` <20080212133446.a521a8bb.akpm@linux-foundation.org>
@ 2008-02-13 11:03       ` Thomas, Sujith
       [not found]       ` <05B550FD4BD2014E841D83547B62600802A6BA72@bgsmsx411.gar.corp.intel.com>
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas, Sujith @ 2008-02-13 11:03 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-acpi, mingo, torvalds, linux-pm

[-- Attachment #1: Type: text/plain, Size: 1054 bytes --]

 
Hi Andrew,
	For time being I am attaching the patch and in the meanwhile
I'll figure out
a way to fix the wordwrap issues. This was what Len Brown also had
recommended.

Regards,
Sujith
> -----Original Message-----
> From: Andrew Morton [mailto:akpm@linux-foundation.org] 
> Sent: Wednesday, February 13, 2008 3:05 AM
> To: Thomas, Sujith
> Cc: lenb@kernel.org; mingo@elte.hu; 
> torvalds@linux-foundation.org; linux-acpi@vger.kernel.org; 
> linux-kernel@vger.kernel.org; 
> linux-pm@lists.linux-foundation.org; Zhang, Rui
> Subject: Re: [Bug-fix]:2.6.25-rc0 Generic thermal management 
> [Patch 1/2]: validating input parameters
> 
> On Tue, 12 Feb 2008 21:27:44 +0530
> "Thomas, Sujith" <sujith.thomas@intel.com> wrote:
> 
> > > The patch is fairly seriously wordwrapped.
> > Should be fixed now.
> 
> No, even after I fixed all the wordwrapping I saw a large amount
> of fuzz and several rejects when trying to apply the patch.
> 
> There's a reason why Len uses his kernel.org account to get 
> real work done ;)
> 

[-- Attachment #2: [Bug-fix]2.6.25-rc0 Generic thermal management [Patch 1 of 2] --]
[-- Type: application/octet-stream, Size: 4042 bytes --]

 drivers/thermal/thermal.c |   63 +++++++++++++++++++++++++++-------------------
 1 files changed, 38 insertions(+), 25 deletions(-)

Index: linux-2.6.24-rc3/drivers/thermal/thermal.c
===================================================================
--- linux-2.6.24-rc3.orig/drivers/thermal/thermal.c
+++ linux-2.6.24-rc3/drivers/thermal/thermal.c
@@ -301,13 +301,24 @@ int thermal_zone_bind_cooling_device(str
 {
 	struct thermal_cooling_device_instance *dev;
 	struct thermal_cooling_device_instance *pos;
+	struct thermal_zone_device *pos1;
+	struct thermal_cooling_device *pos2;
 	int result;
 
 	if (trip >= tz->trips ||
 	    (trip < 0 && trip != THERMAL_TRIPS_NONE))
 		return -EINVAL;
 
-	if (!tz || !cdev)
+	list_for_each_entry(pos1, &thermal_tz_list, node) {
+		if (pos1 == tz)
+			break;
+	}
+	list_for_each_entry(pos2, &thermal_cdev_list, node) {
+		if (pos2 == cdev)
+			break;
+	}
+
+	if (tz != pos1 || cdev != pos2)
 		return -EINVAL;
 
 	dev =
@@ -427,21 +438,24 @@ struct thermal_cooling_device *thermal_c
 	struct thermal_zone_device *pos;
 	int result;
 
+	if (!type)
+		return ERR_PTR(-EINVAL);
+
 	if (strlen(type) >= THERMAL_NAME_LENGTH)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	if (!ops || !ops->get_max_state || !ops->get_cur_state ||
 		!ops->set_cur_state)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL);
 	if (!cdev)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	result = get_idr(&thermal_cdev_idr, &thermal_idr_lock, &cdev->id);
 	if (result) {
 		kfree(cdev);
-		return NULL;
+		return ERR_PTR(result);
 	}
 
 	strcpy(cdev->type, type);
@@ -453,16 +467,14 @@ struct thermal_cooling_device *thermal_c
 	if (result) {
 		release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id);
 		kfree(cdev);
-		return NULL;
+		return ERR_PTR(result);
 	}
 
 	/* sys I/F */
-	if (type) {
-		result = device_create_file(&cdev->device,
-					    &dev_attr_cdev_type);
-		if (result)
-			goto unregister;
-	}
+	result = device_create_file(&cdev->device,
+				    &dev_attr_cdev_type);
+	if (result)
+		goto unregister;
 
 	result = device_create_file(&cdev->device, &dev_attr_max_state);
 	if (result)
@@ -490,7 +502,7 @@ struct thermal_cooling_device *thermal_c
       unregister:
 	release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id);
 	device_unregister(&cdev->device);
-	return NULL;
+	return ERR_PTR(result);
 }
 EXPORT_SYMBOL(thermal_cooling_device_register);
 
@@ -559,18 +571,21 @@ struct thermal_zone_device *thermal_zone
 	int result;
 	int count;
 
+	if (!type)
+		return ERR_PTR(-EINVAL);
+
 	if (strlen(type) >= THERMAL_NAME_LENGTH)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	if (trips > THERMAL_MAX_TRIPS || trips < 0)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	if (!ops || !ops->get_temp)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL);
 	if (!tz)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	INIT_LIST_HEAD(&tz->cooling_devices);
 	idr_init(&tz->idr);
@@ -578,7 +593,7 @@ struct thermal_zone_device *thermal_zone
 	result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id);
 	if (result) {
 		kfree(tz);
-		return NULL;
+		return ERR_PTR(result);
 	}
 
 	strcpy(tz->type, type);
@@ -591,15 +606,13 @@ struct thermal_zone_device *thermal_zone
 	if (result) {
 		release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
 		kfree(tz);
-		return NULL;
+		return ERR_PTR(result);
 	}
 
 	/* sys I/F */
-	if (type) {
-		result = device_create_file(&tz->device, &dev_attr_type);
-		if (result)
-			goto unregister;
-	}
+	result = device_create_file(&tz->device, &dev_attr_type);
+	if (result)
+		goto unregister;
 
 	result = device_create_file(&tz->device, &dev_attr_temp);
 	if (result)
@@ -633,7 +646,7 @@ struct thermal_zone_device *thermal_zone
       unregister:
 	release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
 	device_unregister(&tz->device);
-	return NULL;
+	return ERR_PTR(result);
 }
 EXPORT_SYMBOL(thermal_zone_device_register);
 

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bug-fix]:2.6.25-rc0 Generic thermal management [Patch 1/2]: validating input parameters
       [not found]   ` <05B550FD4BD2014E841D83547B62600802A6B2A7@bgsmsx411.gar.corp.intel.com>
@ 2008-02-12 21:34     ` Andrew Morton
       [not found]     ` <20080212133446.a521a8bb.akpm@linux-foundation.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2008-02-12 21:34 UTC (permalink / raw)
  To: Thomas, Sujith; +Cc: linux-kernel, linux-acpi, mingo, torvalds, linux-pm

On Tue, 12 Feb 2008 21:27:44 +0530
"Thomas, Sujith" <sujith.thomas@intel.com> wrote:

> > The patch is fairly seriously wordwrapped.
> Should be fixed now.

No, even after I fixed all the wordwrapping I saw a large amount
of fuzz and several rejects when trying to apply the patch.

There's a reason why Len uses his kernel.org account to get real work done ;)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Bug-fix]:2.6.25-rc0 Generic thermal management [Patch 1/2]: validating input parameters
       [not found] ` <20080211133827.16140ba0.akpm@linux-foundation.org>
@ 2008-02-12 15:57   ` Thomas, Sujith
       [not found]   ` <05B550FD4BD2014E841D83547B62600802A6B2A7@bgsmsx411.gar.corp.intel.com>
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas, Sujith @ 2008-02-12 15:57 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-acpi, mingo, torvalds, linux-pm

> On Mon, 11 Feb 2008 15:57:06 +0530
> "Thomas, Sujith" <sujith.thomas@intel.com> wrote:

> > From: Thomas Sujith <sujith.thomas@intel.com>
> > 
> > Added sanity checks for interface functions in thermal with
> > other modules such as fan, processor, video etc..
> > 
> > Signed-off-by: Thomas Sujith <sujith.thomas@intel.com>
> > ---
> > drivers/thermal/thermal.c |   69
> > +++++++++++++++++++++++++++++-----------------
> 
> The patch is fairly seriously wordwrapped.
Should be fixed now.
> 
> >  1 files changed, 44 insertions(+), 25 deletions(-)
> > 
> > Index: linux-2.6.24-rc3/drivers/thermal/thermal.c
> > ===================================================================
> > --- linux-2.6.24-rc3.orig/drivers/thermal/thermal.c
> > +++ linux-2.6.24-rc3/drivers/thermal/thermal.c
> > @@ -301,13 +301,27 @@ int thermal_zone_bind_cooling_device(str
> >  {
> >  	struct thermal_cooling_device_instance *dev;
> >  	struct thermal_cooling_device_instance *pos;
> > +	struct thermal_zone_device *pos1;
> > +	struct thermal_cooling_device *pos2;
> >  	int result;
> >  
> > +	if (!tz || !cdev)
> > +		return -EINVAL;
> 
> Is this change actually needed?  It's sloppy for a caller to be
passing
> invalid arguments into a callee, and it's not good for the callee to
just
> hide that sloppiness.
I agree; removed
> 
> > -		return NULL;
> > +		return  ERR_PTR(-EINVAL);
> 
> the patch adds several spaces like this in places where we don't
normally
> put them.
I agree; removed


From: Thomas Sujith <sujith.thomas@intel.com>

Added sanity checks for interface functions in thermal with
other modules such as fan, processor, video etc. Using ERR_PTR
to return errors.
 
Signed-off-by: Thomas Sujith <sujith.thomas@intel.com>
---
 drivers/thermal/thermal.c |   63
+++++++++++++++++++++++++++-------------------
 1 files changed, 38 insertions(+), 25 deletions(-)

Index: linux-2.6.24-rc3/drivers/thermal/thermal.c
===================================================================
--- linux-2.6.24-rc3.orig/drivers/thermal/thermal.c
+++ linux-2.6.24-rc3/drivers/thermal/thermal.c
@@ -301,13 +301,24 @@ int thermal_zone_bind_cooling_device(str
 {
 	struct thermal_cooling_device_instance *dev;
 	struct thermal_cooling_device_instance *pos;
+	struct thermal_zone_device *pos1;
+	struct thermal_cooling_device *pos2;
 	int result;
 
 	if (trip >= tz->trips ||
 	    (trip < 0 && trip != THERMAL_TRIPS_NONE))
 		return -EINVAL;
 
-	if (!tz || !cdev)
+	list_for_each_entry(pos1, &thermal_tz_list, node) {
+		if (pos1 == tz)
+			break;
+	}
+	list_for_each_entry(pos2, &thermal_cdev_list, node) {
+		if (pos2 == cdev)
+			break;
+	}
+
+	if (tz != pos1 || cdev != pos2)
 		return -EINVAL;
 
 	dev =
@@ -427,21 +438,24 @@ struct thermal_cooling_device *thermal_c
 	struct thermal_zone_device *pos;
 	int result;
 
+	if (!type)
+		return ERR_PTR(-EINVAL);
+
 	if (strlen(type) >= THERMAL_NAME_LENGTH)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	if (!ops || !ops->get_max_state || !ops->get_cur_state ||
 		!ops->set_cur_state)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	cdev = kzalloc(sizeof(struct thermal_cooling_device),
GFP_KERNEL);
 	if (!cdev)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	result = get_idr(&thermal_cdev_idr, &thermal_idr_lock,
&cdev->id);
 	if (result) {
 		kfree(cdev);
-		return NULL;
+		return ERR_PTR(result);
 	}
 
 	strcpy(cdev->type, type);
@@ -453,16 +467,14 @@ struct thermal_cooling_device *thermal_c
 	if (result) {
 		release_idr(&thermal_cdev_idr, &thermal_idr_lock,
cdev->id);
 		kfree(cdev);
-		return NULL;
+		return ERR_PTR(result);
 	}
 
 	/* sys I/F */
-	if (type) {
-		result = device_create_file(&cdev->device,
-					    &dev_attr_cdev_type);
-		if (result)
-			goto unregister;
-	}
+	result = device_create_file(&cdev->device,
+				    &dev_attr_cdev_type);
+	if (result)
+		goto unregister;
 
 	result = device_create_file(&cdev->device, &dev_attr_max_state);
 	if (result)
@@ -490,7 +502,7 @@ struct thermal_cooling_device *thermal_c
       unregister:
 	release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id);
 	device_unregister(&cdev->device);
-	return NULL;
+	return ERR_PTR(result);
 }
 EXPORT_SYMBOL(thermal_cooling_device_register);
 
@@ -559,18 +571,21 @@ struct thermal_zone_device *thermal_zone
 	int result;
 	int count;
 
+	if (!type)
+		return ERR_PTR(-EINVAL);
+
 	if (strlen(type) >= THERMAL_NAME_LENGTH)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	if (trips > THERMAL_MAX_TRIPS || trips < 0)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	if (!ops || !ops->get_temp)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL);
 	if (!tz)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	INIT_LIST_HEAD(&tz->cooling_devices);
 	idr_init(&tz->idr);
@@ -578,7 +593,7 @@ struct thermal_zone_device *thermal_zone
 	result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id);
 	if (result) {
 		kfree(tz);
-		return NULL;
+		return ERR_PTR(result);
 	}
 
 	strcpy(tz->type, type);
@@ -591,15 +606,13 @@ struct thermal_zone_device *thermal_zone
 	if (result) {
 		release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
 		kfree(tz);
-		return NULL;
+		return ERR_PTR(result);
 	}
 
 	/* sys I/F */
-	if (type) {
-		result = device_create_file(&tz->device,
&dev_attr_type);
-		if (result)
-			goto unregister;
-	}
+	result = device_create_file(&tz->device, &dev_attr_type);
+	if (result)
+		goto unregister;
 
 	result = device_create_file(&tz->device, &dev_attr_temp);
 	if (result)
@@ -633,7 +646,7 @@ struct thermal_zone_device *thermal_zone
       unregister:
 	release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
 	device_unregister(&tz->device);
-	return NULL;
+	return ERR_PTR(result);
 }
 EXPORT_SYMBOL(thermal_zone_device_register);
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bug-fix]:2.6.25-rc0 Generic thermal management [Patch 1/2]: validating input parameters
       [not found] <05B550FD4BD2014E841D83547B62600802A3A1B0@bgsmsx411.gar.corp.intel.com>
@ 2008-02-11 21:38 ` Andrew Morton
       [not found] ` <20080211133827.16140ba0.akpm@linux-foundation.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2008-02-11 21:38 UTC (permalink / raw)
  To: Thomas, Sujith; +Cc: linux-kernel, linux-acpi, mingo, torvalds, linux-pm

On Mon, 11 Feb 2008 15:57:06 +0530
"Thomas, Sujith" <sujith.thomas@intel.com> wrote:

> From: Thomas Sujith <sujith.thomas@intel.com>
> 
> Added sanity checks for interface functions in thermal with
> other modules such as fan, processor, video etc..
> 
> Signed-off-by: Thomas Sujith <sujith.thomas@intel.com>
> ---
> drivers/thermal/thermal.c |   69
> +++++++++++++++++++++++++++++-----------------

The patch is fairly seriously wordwrapped.

>  1 files changed, 44 insertions(+), 25 deletions(-)
> 
> Index: linux-2.6.24-rc3/drivers/thermal/thermal.c
> ===================================================================
> --- linux-2.6.24-rc3.orig/drivers/thermal/thermal.c
> +++ linux-2.6.24-rc3/drivers/thermal/thermal.c
> @@ -301,13 +301,27 @@ int thermal_zone_bind_cooling_device(str
>  {
>  	struct thermal_cooling_device_instance *dev;
>  	struct thermal_cooling_device_instance *pos;
> +	struct thermal_zone_device *pos1;
> +	struct thermal_cooling_device *pos2;
>  	int result;
>  
> +	if (!tz || !cdev)
> +		return -EINVAL;

Is this change actually needed?  It's sloppy for a caller to be passing
invalid arguments into a callee, and it's not good for the callee to just
hide that sloppiness.

> -		return NULL;
> +		return  ERR_PTR(-EINVAL);

the patch adds several spaces like this in places where we don't normally
put them.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-13 18:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-11 10:27 [Bug-fix]:2.6.25-rc0 Generic thermal management [Patch 1/2]: validating input parameters Thomas, Sujith
     [not found] <05B550FD4BD2014E841D83547B62600802A3A1B0@bgsmsx411.gar.corp.intel.com>
2008-02-11 21:38 ` Andrew Morton
     [not found] ` <20080211133827.16140ba0.akpm@linux-foundation.org>
2008-02-12 15:57   ` Thomas, Sujith
     [not found]   ` <05B550FD4BD2014E841D83547B62600802A6B2A7@bgsmsx411.gar.corp.intel.com>
2008-02-12 21:34     ` Andrew Morton
     [not found]     ` <20080212133446.a521a8bb.akpm@linux-foundation.org>
2008-02-13 11:03       ` Thomas, Sujith
     [not found]       ` <05B550FD4BD2014E841D83547B62600802A6BA72@bgsmsx411.gar.corp.intel.com>
2008-02-13 18:33         ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).