From nobody Mon Apr 6 19:02:28 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 C7E04376466 for ; Wed, 18 Mar 2026 08:57:15 +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=1773824238; cv=none; b=d17hXqe1JVfRI8EHcreZsCUqJBARd+d0uJ8+3jFHV85diQx1qKWlE92sLCrXbu37r+rTNESar3T90QL0hQ7WLjmFUMcVKagZcRpLgPdqKsgD/R0eWuB2CKL6BGGX/QMX6OToJBE4YyENAI2/2NJbdHH3lht+RnAq8AciBNaJ0FY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773824238; c=relaxed/simple; bh=1L2K2n0hNqL4sgl3rla5rLYHyqZVTf8iWg38Iw0h9eQ=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=VO5EsSGLmwE4/ZTNHEbs2Fda6SWl5oT+gId+eHcCy5baik7vlS1NxITpOPIbMI7/7s8YzxmGRp+weRqwxacARx0wZBSb1IRP73MA9hxIIR01UdwhaqJts+nOa/2zdHT50WkvXy5COXwA0IlVG7huGKwjA7T/4GIfZ7tZ7gzJ3kA= 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: 714d146022a811f1a21c59e7364eecb8-20260318 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:c774026d-9a3f-42fa-920d-cc4a7e7c3a9a,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:28739ae63570eba5860e610ed7f65c9d,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: 714d146022a811f1a21c59e7364eecb8-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 1253271398; Wed, 18 Mar 2026 16:57:07 +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 v3] arm: mvebu: fix null pointer when access Date: Wed, 18 Mar 2026 16:56:49 +0800 Message-Id: <20260318085649.2607230-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 | 6 ++++++ 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, 20 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index 04ad651d13a0..25a9853f925e 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -128,8 +128,14 @@ 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); 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