cpuidle: qcom-lpm: Add valid pointer check for genpd's governor data

If cluster idle states disabled genpd_alloc_data() will not allocate
genpd_governor_data, so in such cases genpd_power_off() can
call device's cb cluster_power_cb() if sd count zero.

This change adds valid pointer check.

Change-Id: I70c92378d7118b96bbd2c81176c06235debd3a8a
Signed-off-by: Tushar Nimkar <quic_tnimkar@quicinc.com>
This commit is contained in:
Tushar Nimkar 2023-06-21 15:25:24 +05:30
parent 432be71f52
commit fb6cfd3f20

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/cpu.h>
@ -305,6 +305,9 @@ static int cluster_power_cb(struct notifier_block *nb,
cluster_predict(cluster_gov);
break;
case GENPD_NOTIFY_PRE_OFF:
if (!pd->gd)
return NOTIFY_BAD;
if (!cluster_gov->state_allowed[pd->state_idx])
return NOTIFY_BAD;