Skip to contentSkip to conversation

ufs: host: Remove redundant dev_err()

PATCH Applied Pan Chuang 5 participants 6 messages Jul 17 – Aug 6

Subsystems (5)
lore
Share & tools
lore

Pan Chuang

author
#0 lore raw

PATCH 1/1 ufs: host: Remove redundant dev_err()

Since commit 55b48e23f5c4 ("genirq/devres: Add error handling in devm_request_*_irq()"), devm_request_irq() automatically logs detailed error messages on failure. Remove the now-redundant driver-specific dev_err() calls.

---
 drivers/ufs/host/ufs-mediatek.c | 4 +---
 drivers/ufs/host/ufs-qcom.c     | 2 --
 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/ufs/host/ufs-mediatek.c +1 -3
index 3991a51263a6..98ea9aa2a39c 100644
@@ -2266,10 +2266,8 @@ static int ufs_mtk_config_mcq_irq(struct ufs_hba *hba)
 
 		dev_dbg(hba->dev, "request irq %d intr %s\n", irq, ret ? "failed" : "");
 
-		if (ret) {
-			dev_err(hba->dev, "Cannot request irq %d\n", ret);
+		if (ret)
 			return ret;
-		}
 	}
 	host->is_mcq_intr_enabled = true;
 
drivers/ufs/host/ufs-qcom.c +0 -2
index 291c43448764..7d690ea2fa67 100644
@@ -2431,8 +2431,6 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
 		ret = devm_request_irq(hba->dev, qi[idx].irq, ufs_qcom_mcq_esi_handler,
 				       IRQF_SHARED, "qcom-mcq-esi", qi + idx);
 		if (ret) {
-			dev_err(hba->dev, "%s: Failed to request IRQ for %d, err = %d\n",
-				__func__, qi[idx].irq, ret);
 			/* Free previously allocated IRQs */
 			for (int j = 0; j < idx; j++)
 				devm_free_irq(hba->dev, qi[j].irq, qi + j);
Signature · 1 line
2.34.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Teardown order violation in ufs_qcom_remove() destroys the MSI domain before devres-managed IRQs are freed, leading to a potential Use-After-Free or panic. --

--- Patch [1]: [PATCH] ufs: host: Remove redundant dev_err() --- commit 2d60d33ee1768b4175522f72c450271bc5ddc6ae
Author: Pan Chuang <[email protected]>

ufs: host: Remove redundant dev_err()

Since commit 55b48e23f5c4 ("genirq/devres: Add error handling in devm_request_*_irq()"), devm_request_irq() automatically logs detailed error messages on failure. Remove the now-redundant driver-specific dev_err() calls.

drivers/ufs/host/ufs-qcom.c static int ufs_qcom_config_esi(struct ufs_hba *hba) · line 2436

Quoted 13 lines
drivers/ufs/host/ufs-qcom.c +0 -2
index 291c434487648..7d690ea2fa674 100644
@@ -2431,8 +2431,6 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
 		ret = devm_request_irq(hba->dev, qi[idx].irq, ufs_qcom_mcq_esi_handler,
 				       IRQF_SHARED, "qcom-mcq-esi", qi + idx);
 		if (ret) {
-			dev_err(hba->dev, "%s: Failed to request IRQ for %d, err = %d\n",
-				__func__, qi[idx].irq, ret);
 			/* Free previously allocated IRQs */
 			for (int j = 0; j < idx; j++)
 				devm_free_irq(hba->dev, qi[j].irq, qi + j);

[Severity: High]
This is a pre-existing issue, but since devres-managed IRQs are used here, does ufs_qcom_remove() break teardown symmetry?

In ufs_qcom_remove(), the MSI domain is destroyed manually before devres-managed IRQ handlers are released:

drivers/ufs/host/ufs-qcom.c:ufs_qcom_remove() {
    ...
    ufshcd_pltfrm_remove(pdev);
    if (host->esi_enabled)
        platform_device_msi_free_irqs_all(hba->dev);
    ...
}

When the device is unbound, platform_device_msi_free_irqs_all() destroys the MSI IRQ domain and descriptors before devres runs.

When devm_irq_release() later calls free_irq(), it silently returns early because the descriptor is already gone. This bypasses the critical __synchronize_irq() and kthread_stop() cleanup logic.

Could this permanently leak the threaded IRQ handlers (struct irqaction objects) and cause a use-after-free or kernel panic if a handler is scheduled or running while the driver memory is freed?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#4 lore raw
In reply to Pan Chuang

Pan,

Quoted 4 lines

Since commit 55b48e23f5c4 ("genirq/devres: Add error handling in devm_request_*_irq()"), devm_request_irq() automatically logs detailed error messages on failure. Remove the now-redundant driver-specific dev_err() calls.

Applied to 7.3/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
#5 lore raw
In reply to Pan Chuang
Quoted 6 lines · Pan Chuang

Since commit 55b48e23f5c4 ("genirq/devres: Add error handling in devm_request_*_irq()"), devm_request_irq() automatically logs detailed error messages on failure. Remove the now-redundant driver-specific dev_err() calls.

Applied to 7.3/scsi-queue, thanks!

[1/1] ufs: host: Remove redundant dev_err()

      https://git.kernel.org/mkp/scsi/c/0cad7bd51301
Signature · 1 line
Martin K. Petersen