Skip to content

Commit

Permalink
cxgb3: avoid potential memory leak.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Divy Le Ray authored and David S. Miller committed Nov 26, 2008
1 parent 43a944f commit 5256554
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/net/cxgb3/sge.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,15 @@ static void *alloc_ring(struct pci_dev *pdev, size_t nelem, size_t elem_size,

if (!p)
return NULL;
if (sw_size) {
if (sw_size && metadata) {
s = kcalloc(nelem, sw_size, GFP_KERNEL);

if (!s) {
dma_free_coherent(&pdev->dev, len, p, *phys);
return NULL;
}
}
if (metadata)
*(void **)metadata = s;
}
memset(p, 0, len);
return p;
}
Expand Down

0 comments on commit 5256554

Please sign in to comment.