summaryrefslogtreecommitdiff
path: root/drivers/scsi/ses.c
diff options
context:
space:
mode:
authorTomas Henzl <thenzl@redhat.com>2023-02-02 17:24:51 +0100
committerMartin K. Petersen <martin.petersen@oracle.com>2023-02-21 17:32:04 -0500
commit578797f0c8cbc2e3ec5fc0dab87087b4c7073686 (patch)
treeb65fd78e99321280cd8f20f4f26e35252b11719d /drivers/scsi/ses.c
parent801ab13d50cf3d26170ee073ea8bb4eececb76ab (diff)
scsi: ses: Fix slab-out-of-bounds in ses_intf_remove()
A fix for: BUG: KASAN: slab-out-of-bounds in ses_intf_remove+0x23f/0x270 [ses] Read of size 8 at addr ffff88a10d32e5d8 by task rmmod/12013 When edev->components is zero, accessing edev->component[0] members is wrong. Link: https://lore.kernel.org/r/20230202162451.15346-5-thenzl@redhat.com Cc: stable@vger.kernel.org Signed-off-by: Tomas Henzl <thenzl@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/ses.c')
-rw-r--r--drivers/scsi/ses.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index f8031d0782f7..9d4fb09acc1e 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -856,7 +856,8 @@ static void ses_intf_remove_enclosure(struct scsi_device *sdev)
kfree(ses_dev->page2);
kfree(ses_dev);
- kfree(edev->component[0].scratch);
+ if (edev->components)
+ kfree(edev->component[0].scratch);
put_device(&edev->edev);
enclosure_unregister(edev);