summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJames Bottomley <jejb@linux.ibm.com>2020-11-28 15:27:21 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-11 16:44:06 +0100
commit6069e04a922a0488bcf4f1017d38d18afda8194c (patch)
treec5c36fd788b9210eeb6af784afdabaec807951d4 /drivers
parent70e9a93f0945ea9d5d73b8b3e06a1f0757046a87 (diff)
downloadlinux-6069e04a922a0488bcf4f1017d38d18afda8194c.tar.gz
linux-6069e04a922a0488bcf4f1017d38d18afda8194c.tar.bz2
linux-6069e04a922a0488bcf4f1017d38d18afda8194c.zip
scsi: ses: Don't attach if enclosure has no components
commit 3fe97ff3d94934649abb0652028dd7296170c8d0 upstream. 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. [mkp: Switched to KERN_WARNING since this scenario is common] Link: https://lore.kernel.org/r/c5deac044ac409e32d9ad9968ce0dcbc996bfc7a.camel@linux.ibm.com Cc: stable@vger.kernel.org Reported-by: Ding Hui <dinghui@sangfor.com.cn> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/ses.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 0a1734f34587..b61d7e490606 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -704,6 +704,12 @@ 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_WARNING, sdev, "enclosure has no enumerated components\n");
+ goto err_free;
+ }
+
ses_dev->page1 = buf;
ses_dev->page1_len = len;
buf = NULL;