提交 52565544 编写于 作者: D Divy Le Ray 提交者: David S. Miller

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: NDivy Le Ray <divy@chelsio.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 43a944f3
...@@ -549,16 +549,15 @@ static void *alloc_ring(struct pci_dev *pdev, size_t nelem, size_t elem_size, ...@@ -549,16 +549,15 @@ static void *alloc_ring(struct pci_dev *pdev, size_t nelem, size_t elem_size,
if (!p) if (!p)
return NULL; return NULL;
if (sw_size) { if (sw_size && metadata) {
s = kcalloc(nelem, sw_size, GFP_KERNEL); s = kcalloc(nelem, sw_size, GFP_KERNEL);
if (!s) { if (!s) {
dma_free_coherent(&pdev->dev, len, p, *phys); dma_free_coherent(&pdev->dev, len, p, *phys);
return NULL; return NULL;
} }
}
if (metadata)
*(void **)metadata = s; *(void **)metadata = s;
}
memset(p, 0, len); memset(p, 0, len);
return p; return p;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册