linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: Fix NULL pointer dereference issue
@ 2020-11-16 16:29 Mukesh Ojha
  2020-11-17  7:18 ` Zhang Rui
  0 siblings, 1 reply; 5+ messages in thread
From: Mukesh Ojha @ 2020-11-16 16:29 UTC (permalink / raw)
  To: linux-pm, linux-kernel; +Cc: rui.zhang, daniel.lezcano, amitk, Mukesh Ojha

Cooling stats variable inside thermal_cooling_device_stats_update()
can get NULL. We should add a NULL check on stat inside for sanity.

Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
---
 drivers/thermal/thermal_sysfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index a6f371f..f52708f 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -754,6 +754,9 @@ void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
 {
 	struct cooling_dev_stats *stats = cdev->stats;
 
+	if (!stats)
+		return;
+
 	spin_lock(&stats->lock);
 
 	if (stats->state == new_state)
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


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

end of thread, other threads:[~2020-11-17 12:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 16:29 [PATCH] thermal: Fix NULL pointer dereference issue Mukesh Ojha
2020-11-17  7:18 ` Zhang Rui
2020-11-17  8:57   ` Daniel Lezcano
2020-11-17 11:27     ` Zhang Rui
2020-11-17 12:08       ` Daniel Lezcano

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