]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: ses: Don't attach if enclosure has no components
authorJames Bottomley <jejb@linux.ibm.com>
Sat, 28 Nov 2020 23:27:21 +0000 (15:27 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 15:26:48 +0000 (16:26 +0100)
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>
drivers/scsi/ses.c

index 84b234bbd07dba72d88acd7a5c992ce5e0252c6d..ed9508d9437f590d297279d470e9aa3a0be7cbe2 100644 (file)
@@ -720,6 +720,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;