Skip to contentSkip to conversation

fix some bsg related bugs

PATCH Applied Guixin Liu 2 participants 4 messages Dec 18, 2024 – Jan 10, 2025

Subsystems (2)
lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

v2 cover fix some bsg related bugs

Changes from v1 to v2:
- Add fixes tag to the first patch.
- Add rb tag from Avri, thanks.

Guixin Liu (2):
scsi: ufs: delete bsg_dev when setup bsg fail
scsi: ufs: set bsg_queue to NULL after remove

 drivers/ufs/core/ufs_bsg.c | 2 ++
 1 file changed, 2 insertions(+)
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH v2 1/2 scsi: ufs: delete bsg_dev when setup bsg fail

We should remove the bsg device when bsg_setup_queue() return fail to release the resources.

Fixes df032bf27a41 ("scsi: ufs: Add a bsg endpoint that supports UPIUs")
---
 drivers/ufs/core/ufs_bsg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ufs/core/ufs_bsg.c +1 -0
index 6c09d97ae006..58023f735c19 100644
@@ -257,6 +257,7 @@ int ufs_bsg_probe(struct ufs_hba *hba)
 			NULL, 0);
 	if (IS_ERR(q)) {
 		ret = PTR_ERR(q);
+		device_del(bsg_dev);
 		goto out;
 	}
 
Signature · 1 line
2.43.0
author
#2 lore raw

PATCH v2 2/2 scsi: ufs: set bsg_queue to NULL after remove

In reply to Guixin Liu

Currently, this does not cause any issues, but I believe it is necessary to set bsg_queue to NULL after removing it to prevent potential use-after-free (UAF) access.

---
 drivers/ufs/core/ufs_bsg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ufs/core/ufs_bsg.c +1 -0
index 58023f735c19..8d4ad0a3f2cf 100644
@@ -216,6 +216,7 @@ void ufs_bsg_remove(struct ufs_hba *hba)
 		return;
 
 	bsg_remove_queue(hba->bsg_queue);
+	hba->bsg_queue = NULL;
 
 	device_del(bsg_dev);
 	put_device(bsg_dev);
Signature · 1 line
2.43.0
#3 lore raw
In reply to Guixin Liu

Guixin,

Quoted 3 lines

Guixin Liu (2):
scsi: ufs: delete bsg_dev when setup bsg fail
scsi: ufs: set bsg_queue to NULL after remove

Applied to 6.14/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering