Skip to contentSkip to conversation

fix some bsg related bugs

PATCH Superseded Guixin Liu 2 participants 5 messages Dec 17, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

cover fix some bsg related bugs

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 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.

---
 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
reviewer
#2 lore raw

RE: [PATCH 1/2] scsi: ufs: delete bsg_dev when setup bsg fail

Quoted 3 lines

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

Fixes:

Quoted 1 line

Once added, please add my Reviewed-by.

Thanks,
Avri

Quoted 18 lines
---
 drivers/ufs/core/ufs_bsg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ufs/core/ufs_bsg.c index renamed from drivers/ufs/core/ufs_bsg.c +0 -0

6c09d97ae006..58023f735c19 100644

drivers/ufs/core/ufs_bsg.c +1 -1
@@ -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;
        }
 
--

2.43.0

author
#3 lore raw

PATCH 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
reviewer Reviewed-by on v1 2/2
#4 lore raw

RE: [PATCH 2/2] scsi: ufs: set bsg_queue to NULL after remove

Quoted 4 lines

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.

OK.

Quoted 2 lines
Quoted 18 lines
---
 drivers/ufs/core/ufs_bsg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ufs/core/ufs_bsg.c index renamed from drivers/ufs/core/ufs_bsg.c +0 -0

58023f735c19..8d4ad0a3f2cf 100644

drivers/ufs/core/ufs_bsg.c +1 -1
@@ -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);
--

2.43.0