diff mbox

[2/2] dma: ste_dma40: Fix potential null pointer dereference

Message ID 1378109699-25245-2-git-send-email-sachin.kamat@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sachin Kamat Sept. 2, 2013, 8:14 a.m. UTC
kcalloc can return NULL. Check the pointer before dereferencing.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/dma/ste_dma40.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Linus Walleij Sept. 12, 2013, 9:34 a.m. UTC | #1
On Mon, Sep 2, 2013 at 10:14 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:

> kcalloc can return NULL. Check the pointer before dereferencing.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

I guess Vinod can take this into fixes for v3.12?

Yours,
Linus Walleij
diff mbox

Patch

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index df0a606..82d2b97 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2591,6 +2591,9 @@  dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr,
 	int i;
 
 	sg = kcalloc(periods + 1, sizeof(struct scatterlist), GFP_NOWAIT);
+	if (!sg)
+		return NULL;
+
 	for (i = 0; i < periods; i++) {
 		sg_dma_address(&sg[i]) = dma_addr;
 		sg_dma_len(&sg[i]) = period_len;