]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
DMA: PL330: Check the pointer returned by kzalloc
authorSachin Kamat <sachin.kamat@linaro.org>
Mon, 17 Sep 2012 09:50:23 +0000 (15:20 +0530)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 10 Oct 2012 02:30:56 +0000 (03:30 +0100)
commit 61c6e7531d3b66b33187b8cdd700fd8ab93ffd62 upstream.

kzalloc could return NULL. Hence add a check to avoid
NULL pointer dereference.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
[bwh: Backported to 3.2: adjust context and error label]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/dma/pl330.c

index 571041477ab2984230fb1d6f4f9849276f0f046f..e8eedb79f2dcb45353e1f4b564c4fdb9ec36503b 100644 (file)
@@ -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];