From: Divy Le Ray Date: Wed, 26 Nov 2008 23:35:59 +0000 (-0800) Subject: cxgb3: avoid potential memory leak. X-Git-Tag: v2.6.29-rc1~581^2~381 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=5256554489531f3e177e7308752d8f0681cdd5a6;p=linux-2.6-omap-h63xx.git 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 Signed-off-by: David S. Miller --- diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c index 268f15801ec..bc6a8dcb8cc 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, 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; }