[PATCH v1 10/10] ufs: host: mediatek: Fix invalid access in vccqx handling
peter.wang at mediatek.com
peter.wang at mediatek.com
Mon Aug 11 06:11:26 PDT 2025
From: Alice Chao <alice.chao at mediatek.com>
This patch adds a NULL check before accessing the 'vccqx' pointer
to prevent invalid memory access. This ensures that the function
safely handles cases where 'vccq' and 'vccq2' are not initialized,
improving the robustness of the power management code.
Signed-off-by: Peter Wang <peter.wang at mediatek.com>
Signed-off-by: Alice Chao <alice.chao at mediatek.com>
Reviewed-by: Peter Wang <peter.wang at mediatek.com>
---
drivers/ufs/host/ufs-mediatek.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index ae458c4a7a46..5ef0ba4527e4 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1629,6 +1629,9 @@ static void ufs_mtk_vccqx_set_lpm(struct ufs_hba *hba, bool lpm)
{
struct ufs_vreg *vccqx = NULL;
+ if (!hba->vreg_info.vccq && !hba->vreg_info.vccq2)
+ return;
+
if (hba->vreg_info.vccq)
vccqx = hba->vreg_info.vccq;
else
--
2.45.2
More information about the Linux-mediatek
mailing list