fix some bsg related bugs
Subsystems (2)
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
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
@@ -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
Avri Altman
reviewerRE: [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
Signed-off-by Guixin Liu <[email protected]>
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..58023f735c19100644drivers/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
PATCH 2/2 scsi: ufs: set bsg_queue to NULL after remove
In reply to Guixin LiuCurrently, 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
@@ -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
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_queueto NULL after removing it to prevent potential use-after-free (UAF) access.
OK.
Quoted 2 lines
Signed-off-by Guixin Liu <[email protected]>
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..8d4ad0a3f2cf100644drivers/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