Commit e60ebd38 authored by Charles Han's avatar Charles Han Committed by Pu Lehui
Browse files

gpio: grgpio: Add NULL check in grgpio_probe

stable inclusion
from stable-v5.10.231
commit 4733f68e59bb7b9e3d395699abb18366954b9ba7
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBEANT
CVE: CVE-2024-56634

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4733f68e59bb



--------------------------------

[ 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: 7eb6ce2f ("gpio: Convert to using %pOF instead of full_name")
Signed-off-by: default avatarCharles Han <hanchunchao@inspur.com>
Link: https://lore.kernel.org/r/20241114091822.78199-1-hanchunchao@inspur.com


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Conflicts:
	drivers/gpio/gpio-grgpio.c
[The conflicts were due to some minor issues.]
Signed-off-by: default avatarPu Lehui <pulehui@huawei.com>
parent 908c8608
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -362,6 +362,9 @@ static int grgpio_probe(struct platform_device *ofdev)
	gc->owner = THIS_MODULE;
	gc->to_irq = grgpio_to_irq;
	gc->label = devm_kasprintf(&ofdev->dev, GFP_KERNEL, "%pOF", np);
	if (!gc->label)
		return -ENOMEM;

	gc->base = -1;

	err = of_property_read_u32(np, "nbits", &prop);