scsi: hpsa: Fix allocation size for scsi_host_alloc()
authorAlexey V. Vissarionov <gremlin@altlinux.org>
Wed, 18 Jan 2023 03:12:55 +0000 (06:12 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 18 Jan 2023 23:59:46 +0000 (18:59 -0500)
The 'h' is a pointer to struct ctlr_info, so it's just 4 or 8 bytes, while
the structure itself is much bigger.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: edd163687ea5 ("hpsa: add driver for HP Smart Array controllers.")
Link: https://lore.kernel.org/r/20230118031255.GE15213@altlinux.org
Signed-off-by: Alexey V. Vissarionov <gremlin@altlinux.org>
Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hpsa.c

index 4dbf51e..f6da348 100644 (file)
@@ -5850,7 +5850,7 @@ static int hpsa_scsi_host_alloc(struct ctlr_info *h)
 {
        struct Scsi_Host *sh;
 
-       sh = scsi_host_alloc(&hpsa_driver_template, sizeof(h));
+       sh = scsi_host_alloc(&hpsa_driver_template, sizeof(struct ctlr_info));
        if (sh == NULL) {
                dev_err(&h->pdev->dev, "scsi_host_alloc failed\n");
                return -ENOMEM;