Commit cd2ff826 authored by Sachin Kamat's avatar Sachin Kamat Committed by Ben Hutchings

DMA: PL330: Check the pointer returned by kzalloc

commit 61c6e753 upstream.

kzalloc could return NULL. Hence add a check to avoid
NULL pointer dereference.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Acked-by: default avatarJassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@linux.intel.com>
[bwh: Backported to 3.2: adjust context and error label]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent d912bb41
......@@ -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];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment