Thread (6 messages) 6 messages, 3 authors, 2021-03-18

Re: [PATCH] scsi: ses: Fix crash caused by kfree an invalid pointer

From: Ding Hui <hidden>
Date: 2021-03-18 12:32:57
Also in: linux-scsi, lkml

On 2020/11/29 7:27, James Bottomley wrote:
quoted hunk ↗ jump to hunk
---8>8>8><8<8<8--------
From: James Bottomley <James.Bottomley@HansenPartnership.com>
Subject: [PATCH] scsi: ses: don't attach if enclosure has no components

An enclosure with no components can't usefully be operated by the
driver (since effectively it has nothing to manage), so report the
problem and don't attach.  Not attaching also fixes an oops which
could occur if the driver tries to manage a zero component enclosure.

Reported-by: Ding Hui <redacted>
Cc: stable@vger.kernel.org
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
  drivers/scsi/ses.c | 5 +++++
  1 file changed, 5 insertions(+)
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index c2afba2a5414..9624298b9c89 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -690,6 +690,11 @@ static int ses_intf_add(struct device *cdev,
  		    type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE)
  			components += type_ptr[1];
  	}
+	if (components == 0) {
+		sdev_printk(KERN_ERR, sdev, "enclosure has no enumerated components\n");
+		goto err_free;
+	}
+
  	ses_dev->page1 = buf;
  	ses_dev->page1_len = len;
  	buf = NULL;
Can I ask you to resubmit your patch ("scsi: ses: don't attach if 
enclosure has no components") to kernel, thanks

-- 
Thanks,
- Ding Hui
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help