summaryrefslogtreecommitdiff
path: root/drivers/ufs/host
diff options
context:
space:
mode:
authorAlice Chao <alice.chao@mediatek.com>2025-08-11 16:11:26 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-11-13 23:34:12 +0300
commit22dd4394da5a2e2602bfefbf7568a480e55422b2 (patch)
tree7ce395fa0425e5202e19ab21d5881e0429a819b3 /drivers/ufs/host
parentf394022d753e7414c2bfb0779d8c70081874364d (diff)
downloadlinux-22dd4394da5a2e2602bfefbf7568a480e55422b2.tar.xz
scsi: ufs: host: mediatek: Fix invalid access in vccqx handling
[ Upstream commit 5863638598f5e4f64d2f85b03f376383ca1f2ab7 ] Add 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: Alice Chao <alice.chao@mediatek.com> Reviewed-by: Peter Wang <peter.wang@mediatek.com> Signed-off-by: Peter Wang <peter.wang@mediatek.com> Link: https://lore.kernel.org/r/20250811131423.3444014-11-peter.wang@mediatek.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/ufs/host')
-rw-r--r--drivers/ufs/host/ufs-mediatek.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index c0106fb3792d..2be74662f960 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1426,6 +1426,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