2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/drivers/ufs/host
Nitin Rawat 6300d5c543 scsi: ufs: ufs-qcom: Fix ESI null pointer dereference
ESI/MSI is a performance optimization feature that provides dedicated
interrupts per MCQ hardware queue. This is optional feature and UFS MCQ
should work with and without ESI feature.

Commit e46a28cea2 ("scsi: ufs: qcom: Remove the MSI descriptor abuse")
brings a regression in ESI (Enhanced System Interrupt) configuration that
causes a null pointer dereference when Platform MSI allocation fails.

The issue occurs in when platform_device_msi_init_and_alloc_irqs() in
ufs_qcom_config_esi() fails (returns -EINVAL) but the current code uses
__free() macro for automatic cleanup free MSI resources that were never
successfully allocated.

Unable to handle kernel NULL pointer dereference at virtual
address 0000000000000008

  Call trace:
  mutex_lock+0xc/0x54 (P)
  platform_device_msi_free_irqs_all+0x1c/0x40
  ufs_qcom_config_esi+0x1d0/0x220 [ufs_qcom]
  ufshcd_config_mcq+0x28/0x104
  ufshcd_init+0xa3c/0xf40
  ufshcd_pltfrm_init+0x504/0x7d4
  ufs_qcom_probe+0x20/0x58 [ufs_qcom]

Fix by restructuring the ESI configuration to try MSI allocation first,
before any other resource allocation and instead use explicit cleanup
instead of __free() macro to avoid cleanup of unallocated resources.

Tested on SM8750 platform with MCQ enabled, both with and without
Platform ESI support.

Fixes: e46a28cea2 ("scsi: ufs: qcom: Remove the MSI descriptor abuse")
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Link: https://lore.kernel.org/r/20250811073330.20230-1-quic_nitirawa@quicinc.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2025-08-18 22:25:52 -04:00
..
cdns-pltfrm.c Merge patch series "scsi: ufs: Bug fixes for ufs core and platform drivers" 2024-11-20 22:04:15 -05:00
Kconfig scsi: ufs: rockchip: Initial support for UFS 2025-02-24 19:18:44 -05:00
Makefile scsi: ufs: rockchip: Initial support for UFS 2025-02-24 19:18:44 -05:00
tc-dwc-g210-pci.c scsi: ufs: Replace deprecated PCI functions 2024-11-06 20:45:32 -05:00
tc-dwc-g210-pltfrm.c Merge patch series "scsi: ufs: Bug fixes for ufs core and platform drivers" 2024-11-20 22:04:15 -05:00
tc-dwc-g210.c scsi: ufs: Fix kernel-doc headers 2023-07-31 15:17:50 -04:00
tc-dwc-g210.h
ti-j721e-ufs.c scsi: ufs: Switch back to struct platform_driver::remove() 2024-11-20 21:46:27 -05:00
ufs-exynos.c scsi: ufs: exynos: Fix programming of HCI_UTRL_NEXUS_TYPE 2025-07-14 20:57:00 -04:00
ufs-exynos.h Merge patch series "ufs-exynos stability fixes for gs101" 2025-04-03 09:58:05 -04:00
ufs-hisi.c scsi: ufs: Constify the third pwr_change_notify() argument 2025-02-12 22:25:06 -05:00
ufs-hisi.h
ufs-mediatek-sip.h scsi: ufs: mediatek: Support rtff in PM flow 2024-03-25 21:03:00 -04:00
ufs-mediatek-trace.h scsi: ufs: ufs-mediatek: Support clk-scaling to optimize power consumption 2022-08-22 22:58:30 -04:00
ufs-mediatek.c scsi: ufs: mediatek: Fix out-of-bounds access in MCQ IRQ mapping 2025-08-05 22:10:14 -04:00
ufs-mediatek.h scsi: ufs: host: mediatek: Support FDE (AES) clock scaling 2025-07-24 22:20:10 -04:00
ufs-qcom.c scsi: ufs: ufs-qcom: Fix ESI null pointer dereference 2025-08-18 22:25:52 -04:00
ufs-qcom.h scsi: ufs: ufs-qcom: Enable QUnipro Internal Clock Gating 2025-07-14 18:25:10 -04:00
ufs-renesas.c scsi: ufs: renesas: Add initialization code for R-Car S4-8 ES1.2 2025-03-10 21:35:54 -04:00
ufs-rockchip.c scsi: ufs: rockchip: Simplify bool conversion 2025-03-03 22:11:47 -05:00
ufs-rockchip.h scsi: ufs: rockchip: Initial support for UFS 2025-02-24 19:18:44 -05:00
ufs-sprd.c scsi: ufs: Constify the third pwr_change_notify() argument 2025-02-12 22:25:06 -05:00
ufs-sprd.h scsi: ufs: ufs-unisoc: Add support for Unisoc UFS host controller 2023-01-11 21:17:18 -05:00
ufshcd-dwc.c scsi: ufs: Fix kernel-doc headers 2023-07-31 15:17:50 -04:00
ufshcd-dwc.h
ufshcd-pci.c scsi: ufs: ufs-pci: Add support for Intel Wildcat Lake 2025-08-14 23:20:02 -04:00
ufshcd-pltfrm.c scsi: ufs: core: Fix use-after free in init error and remove paths 2025-02-03 17:20:01 -05:00
ufshcd-pltfrm.h scsi: ufs: pltfrm: Disable runtime PM during removal of glue drivers 2024-11-20 22:03:05 -05:00
ufshci-dwc.h