From: Dan Carpenter <dan.carpenter@linaro.org>
To: Peter Wang <peter.wang@mediatek.com>
Cc: linux-scsi@vger.kernel.org
Subject: [bug report] scsi: ufs: core: Fix runtime suspend error deadlock
Date: Fri, 3 Oct 2025 12:30:20 +0300 [thread overview]
Message-ID: <aN-XrK70ORfuWfEG@stanley.mountain> (raw)
Hello Peter Wang,
Commit f966e02ae521 ("scsi: ufs: core: Fix runtime suspend error
deadlock") from Sep 26, 2025 (linux-next), leads to the following
Smatch static checker warning:
drivers/ufs/core/ufshcd.c:6844 ufshcd_err_handler()
warn: inconsistent returns '&hba->host_sem'.
Locked on : 6691
Unlocked on: 6683,6844
drivers/ufs/core/ufshcd.c
6658 static void ufshcd_err_handler(struct work_struct *work)
6659 {
6660 int retries = MAX_ERR_HANDLER_RETRIES;
6661 struct ufs_hba *hba;
6662 unsigned long flags;
6663 bool needs_restore;
6664 bool needs_reset;
6665 int pmc_err;
6666
6667 hba = container_of(work, struct ufs_hba, eh_work);
6668
6669 dev_info(hba->dev,
6670 "%s started; HBA state %s; powered %d; shutting down %d; saved_err = 0x%x; saved_uic_err = 0x%x; force_reset = %d%s\n",
6671 __func__, ufshcd_state_name[hba->ufshcd_state],
6672 hba->is_powered, hba->shutting_down, hba->saved_err,
6673 hba->saved_uic_err, hba->force_reset,
6674 ufshcd_is_link_broken(hba) ? "; link is broken" : "");
6675
6676 down(&hba->host_sem);
^^^^^^^^^^^^^^^^^^^^
We're holding this semaphore.
6677 spin_lock_irqsave(hba->host->host_lock, flags);
6678 if (ufshcd_err_handling_should_stop(hba)) {
6679 if (hba->ufshcd_state != UFSHCD_STATE_ERROR)
6680 hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;
6681 spin_unlock_irqrestore(hba->host->host_lock, flags);
6682 up(&hba->host_sem);
Released.
6683 return;
6684 }
6685 spin_unlock_irqrestore(hba->host->host_lock, flags);
6686
6687 ufshcd_rpm_get_noresume(hba);
6688 if (hba->pm_op_in_progress) {
6689 ufshcd_link_recovery(hba);
6690 ufshcd_rpm_put(hba);
6691 return;
The patch introduces a new return but doesn't release the hba->host_sem.
The patch was supposed to fix a deadlock but I would have thought it
would introduce a new deadlock...
6692 }
6693 ufshcd_rpm_put(hba);
6694
regards,
dan carpenter
next reply other threads:[~2025-10-03 9:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-03 9:30 Dan Carpenter [this message]
2025-10-03 9:58 ` [bug report] scsi: ufs: core: Fix runtime suspend error deadlock Peter Wang (王信友)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aN-XrK70ORfuWfEG@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=linux-scsi@vger.kernel.org \
--cc=peter.wang@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.