Skip to content

Commit

Permalink
DMA: PL330: Check the pointer returned by kzalloc
Browse files Browse the repository at this point in the history
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>
Cc: Stable <stable@vger.kernel.org>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
  • Loading branch information
Sachin Kamat authored and Vinod Koul committed Sep 18, 2012
1 parent 2e2c682 commit 61c6e75
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/dma/pl330.c
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
num_chan = max_t(int, pi->pcfg.num_peri, 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_err5;
}

for (i = 0; i < num_chan; i++) {
pch = &pdmac->peripherals[i];
Expand Down

0 comments on commit 61c6e75

Please sign in to comment.