summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKunwu Chan <chentao@kylinos.cn>2024-01-15 17:43:30 +0800
committerMadhavan Srinivasan <maddy@linux.ibm.com>2025-11-11 14:39:25 +0530
commit2617bd81ae54128e63e764c48935e572e3dee501 (patch)
tree786f6fc9c4dda8593cc9148337bb0e2301dcd04f
parentf90d28443b1f4dbbbdcfea1be5295f6903acc94c (diff)
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
-rw-r--r--arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
index cb7b9498f291..80d944f29288 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;