diff mbox

[2/2] ses: invalid free in ses_intf_remove_enclosure()

Message ID 20151019101618.GB26688@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Oct. 19, 2015, 10:16 a.m. UTC
If thre aren't any components, then the component[0] is beyond the end
of the array.

Reported-by: "Berry Cheng ??(??)" <chengmiao.cj@alibaba-inc.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index ff474c7..a31114d 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -780,7 +780,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);