linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2] Thermal: Fix synchronization issues in thermal_sys.c
@ 2012-09-27  6:38 Durgadoss R
       [not found] ` <CA+icZUXV21BqzAHwPy5gY_VHEws8hXZ8B=vESuPazpmOSQVHvA@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Durgadoss R @ 2012-09-27  6:38 UTC (permalink / raw)
  To: lenb, rui.zhang; +Cc: linux-acpi, dan.carpenter, hughd, linux-next, Durgadoss R

This patch fixes the following mutex and NULL pointer
problems in thermal_sys.c:
 * mutex_unlock fix in update_temperature function
 * mutex_unlock fix in bind_cdev function
 * NULL check fix in bind_tz function

Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Reported-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
---
v2:
 * Removed unnecessary NULL check in bind_cdev
 * Added 'Reported-by' tags for Sedat and Hugh
 drivers/thermal/thermal_sys.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 4f77d89..e1179d3 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -253,7 +253,7 @@ static void bind_cdev(struct thermal_cooling_device *cdev)
 
 		tzp = pos->tzp;
 		if (!tzp->tbp)
-			return;
+			continue;
 
 		for (i = 0; i < tzp->num_tbps; i++) {
 			if (tzp->tbp[i].cdev || !tzp->tbp[i].match)
@@ -289,7 +289,7 @@ static void bind_tz(struct thermal_zone_device *tz)
 		goto exit;
 	}
 
-	if (!tzp->tbp)
+	if (!tzp || !tzp->tbp)
 		goto exit;
 
 	list_for_each_entry(pos, &thermal_cdev_list, node) {
@@ -390,12 +390,13 @@ static void update_temperature(struct thermal_zone_device *tz)
 	ret = tz->ops->get_temp(tz, &temp);
 	if (ret) {
 		pr_warn("failed to read out thermal zone %d\n", tz->id);
-		return;
+		goto exit;
 	}
 
 	tz->last_temperature = tz->temperature;
 	tz->temperature = temp;
 
+exit:
 	mutex_unlock(&tz->lock);
 }
 
-- 
1.7.9.5

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

end of thread, other threads:[~2012-10-23 10:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-27  6:38 [PATCHv2] Thermal: Fix synchronization issues in thermal_sys.c Durgadoss R
     [not found] ` <CA+icZUXV21BqzAHwPy5gY_VHEws8hXZ8B=vESuPazpmOSQVHvA@mail.gmail.com>
2012-09-27 12:38   ` Sedat Dilek
2012-09-27 14:05     ` Sedat Dilek
2012-09-27 23:48       ` Hugh Dickins
2012-09-28  4:57         ` Sedat Dilek
2012-10-23 10:30         ` Zhang, Rui

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).