From cd2ff82610f26dc1817effaed4627907fbe28079 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 17 Sep 2012 15:20:23 +0530 Subject: [PATCH] DMA: PL330: Check the pointer returned by kzalloc commit 61c6e7531d3b66b33187b8cdd700fd8ab93ffd62 upstream. kzalloc could return NULL. Hence add a check to avoid NULL pointer dereference. Signed-off-by: Sachin Kamat Acked-by: Jassi Brar Signed-off-by: Vinod Koul [bwh: Backported to 3.2: adjust context and error label] Signed-off-by: Ben Hutchings --- drivers/dma/pl330.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 571041477ab2..e8eedb79f2dc 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -858,6 +858,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) /* Initialize channel parameters */ num_chan = max(pdat ? pdat->nr_valid_peri : 0, (u8)pi->pcfg.num_chan); pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); + if (!pdmac->peripherals) { + ret = -ENOMEM; + dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n"); + goto probe_err4; + } for (i = 0; i < num_chan; i++) { pch = &pdmac->peripherals[i]; -- 2.39.5