From: Kiran Padwal Date: Thu, 18 Sep 2014 07:27:47 +0000 (+0530) Subject: spi: pl022: Add missing error check for devm_kzalloc X-Git-Tag: v3.18-rc1~145^2~1^2~1 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=73e3f1eb51888303389f2dc2219c97ce34ca6db0;p=karo-tx-linux.git spi: pl022: Add missing error check for devm_kzalloc Currently this driver is missing a check on the return value of devm_kzalloc, which would cause a NULL pointer dereference in a OOM situation. This patch adds a missing check. Signed-off-by: Kiran Padwal Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 1189cfd96477..7f13f3f7198b 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -2100,6 +2100,10 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) pl022->vendor = id->data; pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int), GFP_KERNEL); + if (!pl022->chipselects) { + status = -ENOMEM; + goto err_no_mem; + } /* * Bus Number Which has been Assigned to this SSP controller @@ -2241,6 +2245,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) amba_release_regions(adev); err_no_ioregion: err_no_gpio: + err_no_mem: spi_master_put(master); return status; }