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 <mojha@codeaurora.org>
This commit is contained in:
Mukesh Ojha 2020-11-16 19:42:54 +05:30
parent 7982ae0c2c
commit 70145df882

View File

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