enic: Check if rq/wq buf not NULL before freeing them
Roopa Prabhu [Tue, 10 Aug 2010 18:55:20 +0000 (18:55 +0000)]
Signed-off-by: Scott Feldman <scofeldm@cisco.com>
Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Vasanthy Kolluri <vkolluri@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

drivers/net/enic/vnic_rq.c
drivers/net/enic/vnic_wq.c

index dbb2aca..b236d7c 100644 (file)
@@ -77,8 +77,10 @@ void vnic_rq_free(struct vnic_rq *rq)
        vnic_dev_free_desc_ring(vdev, &rq->ring);
 
        for (i = 0; i < VNIC_RQ_BUF_BLKS_MAX; i++) {
-               kfree(rq->bufs[i]);
-               rq->bufs[i] = NULL;
+               if (rq->bufs[i]) {
+                       kfree(rq->bufs[i]);
+                       rq->bufs[i] = NULL;
+               }
        }
 
        rq->ctrl = NULL;
index 122e33b..4b2a6c6 100644 (file)
@@ -77,8 +77,10 @@ void vnic_wq_free(struct vnic_wq *wq)
        vnic_dev_free_desc_ring(vdev, &wq->ring);
 
        for (i = 0; i < VNIC_WQ_BUF_BLKS_MAX; i++) {
-               kfree(wq->bufs[i]);
-               wq->bufs[i] = NULL;
+               if (wq->bufs[i]) {
+                       kfree(wq->bufs[i]);
+                       wq->bufs[i] = NULL;
+               }
        }
 
        wq->ctrl = NULL;