Skip to content

Commit 2617bd8

Browse files
KunWuChanmaddy-kerneldev
authored andcommitted
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
1 parent f90d284 commit 2617bd8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ static int mcu_gpiochip_add(struct mcu *mcu)
123123

124124
gc->owner = THIS_MODULE;
125125
gc->label = kasprintf(GFP_KERNEL, "%pfw", dev_fwnode(dev));
126+
if (!gc->label)
127+
return -ENOMEM;
126128
gc->can_sleep = 1;
127129
gc->ngpio = MCU_NUM_GPIO;
128130
gc->base = -1;

0 commit comments

Comments
 (0)