Skip to content

Commit 720fa0c

Browse files
Nitin Rawatvinodkoul
authored andcommitted
scsi: ufs: qcom : Fix NULL pointer dereference in ufs_qcom_setup_clocks
Fix a NULL pointer dereference in ufs_qcom_setup_clocks due to an uninitialized 'host' variable. The variable 'phy' is now assigned after confirming 'host' is not NULL. Call Stack: Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 ufs_qcom_setup_clocks+0x28/0x148 ufs_qcom (P) ufshcd_setup_clocks (drivers/ufs/core/ufshcd-priv.h:142) ufshcd_init (drivers/ufs/core/ufshcd.c:9468) ufshcd_pltfrm_init (drivers/ufs/host/ufshcd-pltfrm.c:504) ufs_qcom_probe+0x28/0x68 ufs_qcom platform_probe (drivers/base/platform.c:1404) really_probe (drivers/base/dd.c:579 drivers/base/dd.c:657) __driver_probe_device (drivers/base/dd.c:799) driver_probe_device (drivers/base/dd.c:829) __driver_attach (drivers/base/dd.c:1216) bus_for_each_dev (drivers/base/bus.c:370) driver_attach (drivers/base/dd.c:1234) bus_add_driver (drivers/base/bus.c:678) driver_register (drivers/base/driver.c:249) __platform_driver_register (drivers/base/platform.c:868) ufs_qcom_pltform_init+0x28/0xff8 ufs_qcom do_one_initcall (init/main.c:1274) do_init_module (kernel/module/main.c:3041) load_module (kernel/module/main.c:3511) init_module_from_file (kernel/module/main.c:3704) __arm64_sys_finit_module (kernel/module/main.c:3715. Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Fixes: 77d2fa5 ("scsi: ufs: qcom : Refactor phy_power_on/off calls") Tested-by: Dmitry Baryshkov <[email protected]> Tested-by: Naresh Kamboju <[email protected]> Tested-by: Neil Armstrong <[email protected]> Reported-by: Aishwarya <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Reported-by: Naresh Kamboju <[email protected]> Closes: https://lore.kernel.org/linux-scsi/CA+G9fYuFQ2dBvYm1iB6rbwT=4b1c8e4NJ3yxqFPGZGUKH3GmMA@mail.gmail.com/T/#t Co-developed-by: Ram Kumar Dwivedi <[email protected]> Signed-off-by: Ram Kumar Dwivedi <[email protected]> Signed-off-by: Nitin Rawat <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Reported-by: Linux Kernel Functional Testing <[email protected]> Tested-by: Linux Kernel Functional Testing <[email protected]> Tested-by: Marek Szyprowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent f0185cd commit 720fa0c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/ufs/host/ufs-qcom.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
11241124
enum ufs_notify_change_status status)
11251125
{
11261126
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
1127-
struct phy *phy = host->generic_phy;
1127+
struct phy *phy;
11281128
int err;
11291129

11301130
/*
@@ -1135,6 +1135,8 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
11351135
if (!host)
11361136
return 0;
11371137

1138+
phy = host->generic_phy;
1139+
11381140
switch (status) {
11391141
case PRE_CHANGE:
11401142
if (on) {

0 commit comments

Comments
 (0)