arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c | 2 ++ 1 file changed, 2 insertions(+)
kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful
by checking the pointer validity.
Cc: Kunwu Chan <kunwu.chan@hotmail.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
index 4d8fa9ed1a67..d1ae66eaa687 100644
--- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
+++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
@@ -120,6 +120,8 @@ static int mcu_gpiochip_add(struct mcu *mcu)
gc->owner = THIS_MODULE;
gc->label = kasprintf(GFP_KERNEL, "%pfw", dev_fwnode(dev));
+ if (!gc->label)
+ return -ENOMEM;
gc->can_sleep = 1;
gc->ngpio = MCU_NUM_GPIO;
gc->base = -1;
--
2.39.2
On Mon, 15 Jan 2024 17:43:30 +0800, Kunwu Chan wrote:
> kasprintf() returns a pointer to dynamically allocated memory
> which can be NULL upon failure. Ensure the allocation was successful
> by checking the pointer validity.
>
>
Applied to powerpc/next.
[1/1] powerpc/83xx: Add a null pointer check to mcu_gpiochip_add
https://git.kernel.org/powerpc/c/2617bd81ae54128e63e764c48935e572e3dee501
Thanks
Le 15/01/2024 à 10:43, Kunwu Chan a écrit : > kasprintf() returns a pointer to dynamically allocated memory > which can be NULL upon failure. Ensure the allocation was successful > by checking the pointer validity. > > Cc: Kunwu Chan <kunwu.chan@hotmail.com> > Signed-off-by: Kunwu Chan <chentao@kylinos.cn> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> > --- > arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c > index 4d8fa9ed1a67..d1ae66eaa687 100644 > --- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c > +++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c > @@ -120,6 +120,8 @@ static int mcu_gpiochip_add(struct mcu *mcu) > > gc->owner = THIS_MODULE; > gc->label = kasprintf(GFP_KERNEL, "%pfw", dev_fwnode(dev)); > + if (!gc->label) > + return -ENOMEM; > gc->can_sleep = 1; > gc->ngpio = MCU_NUM_GPIO; > gc->base = -1;
© 2016 - 2026 Red Hat, Inc.