ARM: mvebu: potential dereference of null pointer
Subsystems (3)
PATCH 1/1 ARM: mvebu: potential dereference of null pointer
From: Minghao Chi <[email protected]>
The return value of kzalloc() needs to be checked. To avoid use of null pointer in case of the failure of alloc.
Reported-by Zeal Robot <[email protected]>
Signed-off-by Minghao Chi <[email protected]>
Signed-off-by ye xingchen <[email protected]>
--- arch/arm/mach-mvebu/board-v7.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-mvebu/board-v7.c +2 -1
@@ -125,7 +125,8 @@ static void __init i2c_quirk(void)struct property *new_compat; new_compat =kzalloc (sizeof (*new_compat),GFP_KERNEL ); - +if (!new_compat) +return ; new_compat->name =kstrdup ("compatible" ,GFP_KERNEL ); new_compat->length =sizeof ("marvell,mv78230-a0-i2c" ); new_compat->value = kstrdup("marvell,mv78230-a0-i2c",
Signature · 1 line
2.25.1
Andrew Lunn
maintainerQuoted 17 lines · On Tue, Jan 17, 2023 at 06:22:04PM +0800, [email protected] wrote:
From: Minghao Chi <[email protected]>
The return value of
kzalloc()needs to be checked. To avoid use of null pointer in case of the failure of alloc.Reported-by Zeal Robot <[email protected]>Signed-off-by Minghao Chi <[email protected]>Signed-off-by ye xingchen <[email protected]>--- arch/arm/mach-mvebu/board-v7.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm/mach-mvebu/board-v7.c +0
-0
arch/arm/mach-mvebu/board-v7.c static void __init i2c_quirk(void) · line 132
Quoted 9 lines
arch/arm/mach-mvebu/board-v7.c +2
-1@@ -125,7 +125,8 @@ static void __init i2c_quirk(void)struct property *new_compat; new_compat =kzalloc (sizeof (*new_compat),GFP_KERNEL ); - +if (!new_compat) +return ; new_compat->name =kstrdup ("compatible" ,GFP_KERNEL ); new_compat->length =sizeof ("marvell,mv78230-a0-i2c" ); new_compat->value = kstrdup("marvell,mv78230-a0-i2c",
Please add a blank line after the return statement.
Also, i find it interested your bot is telling you about kzalloc, but totally ignoring kstrdup().
Andrew
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel