Re: [PATCH v4] arm: mvebu: fix null pointer when access
From: Andrew Lunn
Date: Wed Mar 18 2026 - 09:39:39 EST
On Wed, Mar 18, 2026 at 04:59:23PM +0800, Li Jun wrote:
> the kzalloc&kstrdup may return null pointer, will cause kernel panic.
>
> -Fix null pointer.
>
> Signed-off-by: Li Jun <lijun01@xxxxxxxxxx>
> ---
> arch/arm/mach-mvebu/board-v7.c | 10 ++++++++++
> arch/arm/mach-mvebu/coherency.c | 6 ++++++
> arch/arm/mach-mxs/mach-mxs.c | 4 ++--
> arch/arm/mach-versatile/versatile.c | 6 ++++++
4 versions in less than 24 hours....
Also, please don't mix different machine architectures together in one
patch. They have different Maintainers.
> diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
> index 04ad651d13a0..a3b1aa48162b 100644
> --- a/arch/arm/mach-mvebu/board-v7.c
> +++ b/arch/arm/mach-mvebu/board-v7.c
> @@ -128,11 +128,21 @@ static void __init i2c_quirk(void)
> struct property *new_compat;
>
> new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL);
> + if (!new_compat)
> + return -ENOMEM;
When you compiled this, did you get any sort of warning? As you can
see above i2c_quirk() is a void function.
Andrew