Commit c6cf1f33 authored by Nicholas Mc Guire's avatar Nicholas Mc Guire Committed by Stefan Bader

gpio: pl061: handle failed allocations

BugLink: https://bugs.launchpad.net/bugs/1818813

[ Upstream commit df209c43 ]

devm_kzalloc(), devm_kstrdup() and devm_kasprintf() all can
fail internal allocation and return NULL. Using any of the assigned
objects without checking is not safe. As this is early in the boot
phase and these allocations really should not fail, any failure here
is probably an indication of a more serious issue so it makes little
sense to try and rollback the previous allocated resources or try to
continue;  but rather the probe function is simply exited with -ENOMEM.
Signed-off-by: default avatarNicholas Mc Guire <hofrat@osadl.org>
Fixes: 684284b6 ("ARM: integrator: add MMCI device to IM-PD1")
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 5d30e0cd
...@@ -394,7 +394,11 @@ static int __init_refok impd1_probe(struct lm_device *dev) ...@@ -394,7 +394,11 @@ static int __init_refok impd1_probe(struct lm_device *dev)
sizeof(*lookup) + 3 * sizeof(struct gpiod_lookup), sizeof(*lookup) + 3 * sizeof(struct gpiod_lookup),
GFP_KERNEL); GFP_KERNEL);
chipname = devm_kstrdup(&dev->dev, devname, GFP_KERNEL); chipname = devm_kstrdup(&dev->dev, devname, GFP_KERNEL);
mmciname = kasprintf(GFP_KERNEL, "lm%x:00700", dev->id); mmciname = devm_kasprintf(&dev->dev, GFP_KERNEL,
"lm%x:00700", dev->id);
if (!lookup || !chipname || !mmciname)
return -ENOMEM;
lookup->dev_id = mmciname; lookup->dev_id = mmciname;
/* /*
* Offsets on GPIO block 1: * Offsets on GPIO block 1:
......
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