From: Kunwu Chan Date: Mon, 15 Jan 2024 09:43:30 +0000 (+0800) Subject: powerpc/83xx: Add a null pointer check to mcu_gpiochip_add X-Git-Tag: v6.19-rc1~106^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2617bd81ae54128e63e764c48935e572e3dee501;p=thirdparty%2Flinux.git powerpc/83xx: Add a null pointer check to mcu_gpiochip_add kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity. Signed-off-by: Kunwu Chan Signed-off-by: Madhavan Srinivasan Link: https://patch.msgid.link/20240115094330.33014-1-chentao@kylinos.cn --- diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c index cb7b9498f291f..80d944f292885 100644 --- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c +++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c @@ -123,6 +123,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;