From 70145df882580537f337a53f7b871922e8aa4f1f Mon Sep 17 00:00:00 2001 From: Mukesh Ojha Date: Mon, 16 Nov 2020 19:42:54 +0530 Subject: [PATCH] FROMLIST: thermal: Fix NULL pointer dereference issue Cooling stats variable inside thermal_cooling_device_stats_update() can get NULL. We should add a valid check on stat before using it. Bug: 173355233 Link: https://lore.kernel.org/lkml/1605544181-5348-1-git-send-email-mojha@codeaurora.org/ Change-Id: I48105dcf8ff81d272534c59b7120a6d9fc831d04 Signed-off-by: Mukesh Ojha --- 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 aa99edb4dff7..4dce4a8f71ed 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -770,6 +770,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)