From: Sachin Kamat Date: Mon, 17 Sep 2012 09:50:23 +0000 (+0530) Subject: DMA: PL330: Check the pointer returned by kzalloc X-Git-Tag: v3.2.31~83 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cd2ff82610f26dc1817effaed4627907fbe28079;p=karo-tx-linux.git 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 --- 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];