aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hpsa.c
diff options
context:
space:
mode:
authorScott Teel <scott.teel@hp.com>2011-10-26 17:21:12 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-10-30 06:34:04 -0400
commitb7ec021fe6fe979dbd4e62604a4942f964b12864 (patch)
tree1fb695d21736aa12d6144fcd373aee9fe1b6dc54 /drivers/scsi/hpsa.c
parentcfe5badcab2e993e71ebebbc07c21c270e5580c0 (diff)
[SCSI] hpsa: fix potential array overflow in hpsa_update_scsi_devices
The currentsd[] array in hpsa_update_scsi_devices had room for 256 devices. The code was iterating over however many physical and logical devices plus an additional number of possible external MSA2XXX controllers, which together could potentially exceed 256. We increased the size of the currentsd array to 1024 + 1024 + 32 + 1 elements to reflect a reasonable maximum possible number of devices which might be encountered. We also don't just walk off the end of the array if the array controller reports more devices than we are prepared to handle, we just ignore the excessive devices. Signed-off-by: Scott Teel <scott.teel@hp.com> Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/hpsa.c')
-rw-r--r--drivers/scsi/hpsa.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index f661ad1e500..f3fd9f1711f 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1734,7 +1734,6 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
1734 if (is_scsi_rev_5(h)) 1734 if (is_scsi_rev_5(h))
1735 return 0; /* p1210m doesn't need to do this. */ 1735 return 0; /* p1210m doesn't need to do this. */
1736 1736
1737#define MAX_MSA2XXX_ENCLOSURES 32
1738 if (*nmsa2xxx_enclosures >= MAX_MSA2XXX_ENCLOSURES) { 1737 if (*nmsa2xxx_enclosures >= MAX_MSA2XXX_ENCLOSURES) {
1739 dev_warn(&h->pdev->dev, "Maximum number of MSA2XXX " 1738 dev_warn(&h->pdev->dev, "Maximum number of MSA2XXX "
1740 "enclosures exceeded. Check your hardware " 1739 "enclosures exceeded. Check your hardware "
@@ -1868,6 +1867,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
1868 1867
1869 /* Allocate the per device structures */ 1868 /* Allocate the per device structures */
1870 for (i = 0; i < ndevs_to_allocate; i++) { 1869 for (i = 0; i < ndevs_to_allocate; i++) {
1870 if (i >= HPSA_MAX_DEVICES) {
1871 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded."
1872 " %d devices ignored.\n", HPSA_MAX_DEVICES,
1873 ndevs_to_allocate - HPSA_MAX_DEVICES);
1874 break;
1875 }
1876
1871 currentsd[i] = kzalloc(sizeof(*currentsd[i]), GFP_KERNEL); 1877 currentsd[i] = kzalloc(sizeof(*currentsd[i]), GFP_KERNEL);
1872 if (!currentsd[i]) { 1878 if (!currentsd[i]) {
1873 dev_warn(&h->pdev->dev, "out of memory at %s:%d\n", 1879 dev_warn(&h->pdev->dev, "out of memory at %s:%d\n",