From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kyoungrul Kim <k831.kim@samsung.com>,
Minwoo Im <minwoo.im@samsung.com>,
Bart Van Assche <bvanassche@acm.org>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Sasha Levin <sashal@kernel.org>,
James.Bottomley@HansenPartnership.com, peter.wang@mediatek.com,
manivannan.sadhasivam@linaro.org, avri.altman@wdc.com,
beanhuo@micron.com, ahalaney@redhat.com,
linux-scsi@vger.kernel.org
Subject: [PATCH AUTOSEL 6.6 14/17] scsi: ufs: core: Remove SCSI host only if added
Date: Sun, 28 Jul 2024 12:06:50 -0400 [thread overview]
Message-ID: <20240728160709.2052627-14-sashal@kernel.org> (raw)
In-Reply-To: <20240728160709.2052627-1-sashal@kernel.org>
From: Kyoungrul Kim <k831.kim@samsung.com>
[ Upstream commit 7cbff570dbe8907e23bba06f6414899a0fbb2fcc ]
If host tries to remove ufshcd driver from a UFS device it would cause a
kernel panic if ufshcd_async_scan fails during ufshcd_probe_hba before
adding a SCSI host with scsi_add_host and MCQ is enabled since SCSI host
has been defered after MCQ configuration introduced by commit 0cab4023ec7b
("scsi: ufs: core: Defer adding host to SCSI if MCQ is supported").
To guarantee that SCSI host is removed only if it has been added, set the
scsi_host_added flag to true after adding a SCSI host and check whether it
is set or not before removing it.
Signed-off-by: Kyoungrul Kim <k831.kim@samsung.com>
Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
Link: https://lore.kernel.org/r/20240627085104epcms2p5897a3870ea5c6416aa44f94df6c543d7@epcms2p5
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ufs/core/ufshcd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 808979a093505..df36b141d4431 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10114,7 +10114,8 @@ void ufshcd_remove(struct ufs_hba *hba)
blk_mq_destroy_queue(hba->tmf_queue);
blk_put_queue(hba->tmf_queue);
blk_mq_free_tag_set(&hba->tmf_tag_set);
- scsi_remove_host(hba->host);
+ if (hba->scsi_host_added)
+ scsi_remove_host(hba->host);
/* disable interrupts */
ufshcd_disable_intr(hba, hba->intr_mask);
ufshcd_hba_stop(hba);
@@ -10389,6 +10390,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
dev_err(hba->dev, "scsi_add_host failed\n");
goto out_disable;
}
+ hba->scsi_host_added = true;
}
hba->tmf_tag_set = (struct blk_mq_tag_set) {
@@ -10470,7 +10472,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
free_tmf_tag_set:
blk_mq_free_tag_set(&hba->tmf_tag_set);
out_remove_scsi_host:
- scsi_remove_host(hba->host);
+ if (hba->scsi_host_added)
+ scsi_remove_host(hba->host);
out_disable:
hba->is_irq_enabled = false;
ufshcd_hba_exit(hba);
--
2.43.0
next prev parent reply other threads:[~2024-07-28 16:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-28 16:06 [PATCH AUTOSEL 6.6 01/17] PCI: Add ACS quirk for Broadcom BCM5760X NIC Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 02/17] PCI: Use preserve_config in place of pci_flags Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 03/17] usb: cdns3: Add quirk flag to enable suspend residency Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 04/17] usb: cdns3-ti: Add workaround for Errata i2409 Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 05/17] usb: dwc2: gadget: Don't write invalid mapped sg entries into dma_desc with iommu enabled Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 06/17] usb: typec: ucsi: Fix null pointer dereference in trace Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 07/17] MIPS: Loongson64: DTS: Fix msi node for ls7a Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 08/17] MIPS: Loongson64: DTS: Fix PCIe port nodes " Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 09/17] PCI/AER: Disable AER service on suspend Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 10/17] ASoC: Intel: sof_sdw: fix jack detection on ADL-N variant RVP Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 11/17] ASoC: Intel: sof_sdw: add quirk for Dell SKU 0B8C Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 12/17] usb: gadget: aspeed_udc: validate endpoint index for ast udc Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 13/17] PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0) Sasha Levin
2024-07-28 16:06 ` Sasha Levin [this message]
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 15/17] PCI: vmd: Create domain symlink before pci_bus_add_devices() Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 16/17] PCI: Add missing bridge lock to pci_bus_lock() Sasha Levin
2024-07-28 16:06 ` [PATCH AUTOSEL 6.6 17/17] ALSA: usb: Fix UBSAN warning in parse_audio_unit() Sasha Levin
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=20240728160709.2052627-14-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=ahalaney@redhat.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=k831.kim@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=martin.petersen@oracle.com \
--cc=minwoo.im@samsung.com \
--cc=peter.wang@mediatek.com \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox