Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <chentao@kylinos.cn>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20240115094330.33014-1-chentao@kylinos.cn

authored by

Kunwu Chan and committed by
Madhavan Srinivasan
2617bd81 f90d2844

+2
+2
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
··· 123 123 124 124 gc->owner = THIS_MODULE; 125 125 gc->label = kasprintf(GFP_KERNEL, "%pfw", dev_fwnode(dev)); 126 + if (!gc->label) 127 + return -ENOMEM; 126 128 gc->can_sleep = 1; 127 129 gc->ngpio = MCU_NUM_GPIO; 128 130 gc->base = -1;