IB/ipath: fix for crash on module unload, if cfgports < portcnt
authorBryan O'Sullivan <bos@pathscale.com>
Fri, 25 Aug 2006 18:24:28 +0000 (11:24 -0700)
committerRoland Dreier <rolandd@cisco.com>
Fri, 22 Sep 2006 22:22:27 +0000 (15:22 -0700)
Allocate enough pointers for all possible ports, to avoid problems in
cleanup/unload.

Signed-off-by: Bryan O'Sullivan <bryan.osullivan@qlogic.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/ipath/ipath_init_chip.c

index 414cdd1d80a6fa8893121786825bc5646cd8d385..c63de8f0fa9ecacb7c095186a27778c73f9947f5 100644 (file)
@@ -240,7 +240,11 @@ static int init_chip_first(struct ipath_devdata *dd,
                          "only supports %u\n", ipath_cfgports,
                          dd->ipath_portcnt);
        }
-       dd->ipath_pd = kzalloc(sizeof(*dd->ipath_pd) * dd->ipath_cfgports,
+       /*
+        * Allocate full portcnt array, rather than just cfgports, because
+        * cleanup iterates across all possible ports.
+        */
+       dd->ipath_pd = kzalloc(sizeof(*dd->ipath_pd) * dd->ipath_portcnt,
                               GFP_KERNEL);
 
        if (!dd->ipath_pd) {