gpio: grgpio: Add NULL check in grgpio_probe
[ Upstream commit 050b23d081da0f29474de043e9538c1f7a351b3b ] devm_kasprintf() can return a NULL pointer on failure,but this returned value in grgpio_probe is not checked. Add NULL check in grgpio_probe, to handle kernel NULL pointer dereference error. Cc: stable@vger.kernel.org Fixes: 7eb6ce2f2723 ("gpio: Convert to using %pOF instead of full_name") Signed-off-by: Charles Han <hanchunchao@inspur.com> Link: https://lore.kernel.org/r/20241114091822.78199-1-hanchunchao@inspur.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
9e9f831a8d
commit
a45ced812e
1 changed files with 3 additions and 0 deletions
|
@ -363,6 +363,9 @@ static int grgpio_probe(struct platform_device *ofdev)
|
||||||
gc->owner = THIS_MODULE;
|
gc->owner = THIS_MODULE;
|
||||||
gc->to_irq = grgpio_to_irq;
|
gc->to_irq = grgpio_to_irq;
|
||||||
gc->label = devm_kasprintf(dev, GFP_KERNEL, "%pOF", np);
|
gc->label = devm_kasprintf(dev, GFP_KERNEL, "%pOF", np);
|
||||||
|
if (!gc->label)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
gc->base = -1;
|
gc->base = -1;
|
||||||
|
|
||||||
err = of_property_read_u32(np, "nbits", &prop);
|
err = of_property_read_u32(np, "nbits", &prop);
|
||||||
|
|
Loading…
Reference in a new issue