diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-09-17 15:20:23 +0530 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2012-10-10 03:30:56 +0100 |
commit | cd2ff82610f26dc1817effaed4627907fbe28079 (patch) | |
tree | 43dc7e903f7359d481be4b32cc025c500c90cdfb /drivers/dma | |
parent | d912bb414b168204391f4a0fa8ae2e814c770fe8 (diff) |
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 <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>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/pl330.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 571041477ab..e8eedb79f2d 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]; |