mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
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:
committed by
Madhavan Srinivasan
parent
f90d28443b
commit
2617bd81ae
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user