From nobody Mon Apr 6 18:56:34 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A0DB39478B for ; Wed, 18 Mar 2026 08:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773824395; cv=none; b=Doft2/W1ZQ2quxqppWaXB/fow8EQidyR8FXZgSOz9FfTgeqNFiO8peGEKuUgyre321K3zxCnj4E9UgcqydLXoUL7gembvVaVXGd0ZV5mMVjhcOzy66oTQAD7kMC9xzF6zmnk40Cw/zU8dmlF6wJjr//VzGgSHsuCH1jlEpH1USE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773824395; c=relaxed/simple; bh=+X5pOGVrQj3ffE5MjHvdIRZV2Z1hIky402QDMBZZdZQ=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=uVAdPlA4fX3tYBsAl9Bi63RhfL7DcDtxM9x0fXZpwLf49471aeMJnqgix6UlZOQwfTLNe5/9ryJJenHZfBhAcuCThzmMQNHJcFcpUdj5KeFLJVMh+UUvBRPaHsWg6vfEueV0A+gFscyTuTEI8wcw7o3Y6nOgzt6OgrPlPA4zuAE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: cefe425022a811f1a21c59e7364eecb8-20260318 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:7024ae2f-b491-4430-9123-d689acc41d88,IP:0,U RL:0,TC:0,Content:-25,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:89c9d04,CLOUDID:42526a47f54d3461bce1cd4d7d153b8e,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850|898,TC:nil,Content:0|15|50,EDM:5 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: cefe425022a811f1a21c59e7364eecb8-20260318 X-User: lijun01@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 294216803; Wed, 18 Mar 2026 16:59:44 +0800 From: Li Jun To: andrew@lunn.ch, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, lijun01@kylinos.cn Subject: [PATCH v4] arm: mvebu: fix null pointer when access Date: Wed, 18 Mar 2026 16:59:23 +0800 Message-Id: <20260318085923.2610585-1-lijun01@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" the kzalloc&kstrdup may return null pointer, will cause kernel panic. -Fix null pointer. Signed-off-by: Li Jun --- 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; =20 new_compat =3D kzalloc(sizeof(*new_compat), GFP_KERNEL); + if (!new_compat) + return -ENOMEM; =20 new_compat->name =3D kstrdup("compatible", GFP_KERNEL); + if (!mew_compat->name) { + kfree(new_compat); + return -ENOMEM; + } new_compat->length =3D sizeof("marvell,mv78230-a0-i2c"); new_compat->value =3D kstrdup("marvell,mv78230-a0-i2c", GFP_KERNEL); + if (!mew_compat->value) { + kfree(new_compat); + return -ENOMEM; + } =20 of_update_property(np, new_compat); } diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherenc= y.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(struc= t device_node *np) struct property *p; =20 p =3D kzalloc(sizeof(*p), GFP_KERNEL); + if (!p) + return -ENOMEM; p->name =3D 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 o= ui) =20 newmac =3D kzalloc(sizeof(*newmac) + 6, GFP_KERNEL); if (!newmac) - return; + return -ENOMEM; newmac->value =3D newmac + 1; newmac->length =3D 6; =20 newmac->name =3D kstrdup("local-mac-address", GFP_KERNEL); if (!newmac->name) { kfree(newmac); - return; + return -ENOMEM; } =20 /* 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; =20 newprop->name =3D kstrdup("status", GFP_KERNEL); + if (!newprop->name) + goto out_put_node; + newprop->value =3D kstrdup("disabled", GFP_KERNEL); + if (!newprop->value) + goto out_put_node; + newprop->length =3D sizeof("disabled"); of_update_property(np, newprop); =20 --=20 2.25.1