]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: ufs: host: mediatek: Fix invalid access in vccqx handling
authorAlice Chao <alice.chao@mediatek.com>
Mon, 11 Aug 2025 13:11:26 +0000 (21:11 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:02 +0000 (15:37 -0500)
[ 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>
drivers/ufs/host/ufs-mediatek.c

index 82160da8ec71bee414f6b1cd159e87932b68a371..bb0be6bed1bcab79fbc5af93d358eeb3c7bef362 100644 (file)
@@ -1589,6 +1589,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