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
This commit is contained in:
Kunwu Chan
2024-01-15 17:43:30 +08:00
committed by Madhavan Srinivasan
parent f90d28443b
commit 2617bd81ae

View File

@@ -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;