From: Gregory CLEMENT <gregory.clement@bootlin.com>
To: Li Jun <lijun01@kylinos.cn>,
andrew@lunn.ch, sebastian.hesselbarth@gmail.com,
linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, lijun01@kylinos.cn
Subject: Re: [PATCH v4] arm: mvebu: fix null pointer when access
Date: Wed, 18 Mar 2026 10:33:53 +0100 [thread overview]
Message-ID: <87a4w55vni.fsf@BLaptop.bootlin.com> (raw)
In-Reply-To: <20260318085923.2610585-1-lijun01@kylinos.cn>
Hello Li Jun,
This patch looks very broken, see
https://sashiko.dev/#/patchset/20260318085923.2610585-1-lijun01%40kylinos.cn
> the kzalloc&kstrdup may return null pointer, will cause kernel panic.
>
> -Fix null pointer.
You could improve this commit log.
>
> Signed-off-by: Li Jun <lijun01@kylinos.cn>
When you iterate you should add a changelog here.
Gregory
> ---
> 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 files changed, 24 insertions(+), 2 deletions(-)
>
> 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;
>
> new_compat->name = kstrdup("compatible", GFP_KERNEL);
> + if (!mew_compat->name) {
> + kfree(new_compat);
> + return -ENOMEM;
> + }
> new_compat->length = sizeof("marvell,mv78230-a0-i2c");
> new_compat->value = kstrdup("marvell,mv78230-a0-i2c",
> GFP_KERNEL);
> + if (!mew_compat->value) {
> + kfree(new_compat);
> + return -ENOMEM;
> + }
>
> of_update_property(np, new_compat);
> }
> diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
> index a6b621ff0b87..2c1668f3174c 100644
> --- a/arch/arm/mach-mvebu/coherency.c
> +++ b/arch/arm/mach-mvebu/coherency.c
> @@ -191,7 +191,13 @@ static void __init armada_375_380_coherency_init(struct device_node *np)
> struct property *p;
>
> p = kzalloc(sizeof(*p), GFP_KERNEL);
> + if (!p)
> + return -ENOMEM;
> p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
> + if (!p->name) {
> + kfree(p);
> + return -ENOMEM;
> + }
> of_add_property(cache_dn, p);
> }
> }
> diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
> index 6e017fa306c8..16506d9392b4 100644
> --- a/arch/arm/mach-mxs/mach-mxs.c
> +++ b/arch/arm/mach-mxs/mach-mxs.c
> @@ -178,14 +178,14 @@ static void __init update_fec_mac_prop(enum mac_oui oui)
>
> newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
> if (!newmac)
> - return;
> + return -ENOMEM;
> newmac->value = newmac + 1;
> newmac->length = 6;
>
> newmac->name = kstrdup("local-mac-address", GFP_KERNEL);
> if (!newmac->name) {
> kfree(newmac);
> - return;
> + return -ENOMEM;
> }
>
> /*
> diff --git a/arch/arm/mach-versatile/versatile.c b/arch/arm/mach-versatile/versatile.c
> index f0c80d4663ca..07f2a299c770 100644
> --- a/arch/arm/mach-versatile/versatile.c
> +++ b/arch/arm/mach-versatile/versatile.c
> @@ -147,7 +147,13 @@ static void __init versatile_dt_pci_init(void)
> goto out_put_node;
>
> newprop->name = kstrdup("status", GFP_KERNEL);
> + if (!newprop->name)
> + goto out_put_node;
> +
> newprop->value = kstrdup("disabled", GFP_KERNEL);
> + if (!newprop->value)
> + goto out_put_node;
> +
> newprop->length = sizeof("disabled");
> of_update_property(np, newprop);
>
> --
> 2.25.1
>
--
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2026-03-18 9:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 8:59 [PATCH v4] arm: mvebu: fix null pointer when access Li Jun
2026-03-18 9:33 ` Gregory CLEMENT [this message]
2026-03-18 13:38 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a4w55vni.fsf@BLaptop.bootlin.com \
--to=gregory.clement@bootlin.com \
--cc=andrew@lunn.ch \
--cc=lijun01@kylinos.cn \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=sebastian.hesselbarth@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.