IB/qib: Fix module-level leak
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Wed, 3 Jul 2013 17:50:28 +0000 (13:50 -0400)
committerRoland Dreier <roland@purestorage.com>
Thu, 11 Jul 2013 23:46:44 +0000 (16:46 -0700)
The vzalloc()'ed field physshadow is leaked on module unload.

This patch adds vfree after the sibling page shadow is freed.

Reported-by: Dean Luick <dean.luick@intel.com>
Reviewed-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/qib/qib_init.c

index fdae42973056932f2ccdeba33af3327617384d3d..36e048e0e1d93bca227707a2c5e569ec4a851a78 100644 (file)
@@ -1350,7 +1350,7 @@ static void cleanup_device_data(struct qib_devdata *dd)
        if (dd->pageshadow) {
                struct page **tmpp = dd->pageshadow;
                dma_addr_t *tmpd = dd->physshadow;
-               int i, cnt = 0;
+               int i;
 
                for (ctxt = 0; ctxt < dd->cfgctxts; ctxt++) {
                        int ctxt_tidbase = ctxt * dd->rcvtidcnt;
@@ -1363,13 +1363,13 @@ static void cleanup_device_data(struct qib_devdata *dd)
                                               PAGE_SIZE, PCI_DMA_FROMDEVICE);
                                qib_release_user_pages(&tmpp[i], 1);
                                tmpp[i] = NULL;
-                               cnt++;
                        }
                }
 
-               tmpp = dd->pageshadow;
                dd->pageshadow = NULL;
                vfree(tmpp);
+               dd->physshadow = NULL;
+               vfree(tmpd);
        }
 
        /*