aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cxgb3/sge.c
diff options
context:
space:
mode:
authorDivy Le Ray <divy@chelsio.com>2008-11-26 18:35:59 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-26 18:35:59 -0500
commit5256554489531f3e177e7308752d8f0681cdd5a6 (patch)
tree4ce0f2fe12ef0a9654bc939bd5b015cbfc297647 /drivers/net/cxgb3/sge.c
parent43a944f37364e22fff4cbc1e12d227b196e47612 (diff)
cxgb3: avoid potential memory leak.
Add consistency in alloc_ring() parameter checking to avoid potential memory leaks. alloc_ring() callers are correct fo far. Signed-off-by: Divy Le Ray <divy@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/cxgb3/sge.c')
-rw-r--r--drivers/net/cxgb3/sge.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 268f15801ec6..bc6a8dcb8cce 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -549,16 +549,15 @@ static void *alloc_ring(struct pci_dev *pdev, size_t nelem, size_t elem_size,
549 549
550 if (!p) 550 if (!p)
551 return NULL; 551 return NULL;
552 if (sw_size) { 552 if (sw_size && metadata) {
553 s = kcalloc(nelem, sw_size, GFP_KERNEL); 553 s = kcalloc(nelem, sw_size, GFP_KERNEL);
554 554
555 if (!s) { 555 if (!s) {
556 dma_free_coherent(&pdev->dev, len, p, *phys); 556 dma_free_coherent(&pdev->dev, len, p, *phys);
557 return NULL; 557 return NULL;
558 } 558 }
559 }
560 if (metadata)
561 *(void **)metadata = s; 559 *(void **)metadata = s;
560 }
562 memset(p, 0, len); 561 memset(p, 0, len);
563 return p; 562 return p;
564} 563}