[PATCH] scsi: myrs: Fix scsi_device reference leak in myrs_log_event()

Wentao Liang posted 1 patch 1 week ago
drivers/scsi/myrs.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] scsi: myrs: Fix scsi_device reference leak in myrs_log_event()
Posted by Wentao Liang 1 week ago
scsi_device_lookup() returns a scsi_device with an extra reference
that the caller has to drop with scsi_device_put(). The physical device
event handler never releases it, so the scsi_device reference is leaked
for every physical device event reported by the controller.

Drop the reference after the device state has been updated.

Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/scsi/myrs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index afd68225221a..79ee3a352524 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -875,6 +875,8 @@ static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev)
 				break;
 			}
 		}
+		if (sdev)
+			scsi_device_put(sdev);
 		break;
 	case 'L':
 		shost_printk(KERN_INFO, shost,
-- 
2.34.1