From nobody Mon Apr 6 18:29:07 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 53613396B7B for ; Wed, 18 Mar 2026 11:08:56 +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=1773832139; cv=none; b=NGOmgT89kJuplMvLTiaQEXQbE92ic9dVyw9o7gQV/HFb3K1qdK18h6pcEBISjwfl6FtuMH+figO/vTuYd1NGfRpcsrRxAYOReo7qIkZ7Pwo4ugJqx3lCUeyKAHAtIql8iq06AHqOCJi2Z0gDkXwWdAvSuMwiPCn7THR+5owPZJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773832139; c=relaxed/simple; bh=Sg+FPLUmwDhB8zAf3K2hm7oMai6uSGhDNOeJKiECIao=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=VZOyFmrPjmvlbWUJcsS/+iRqepALGJOnLyAbSjPAMRyYbDM1WQ8hrb6zRXwzhs/vJbVzBKhOdkgOJM68rMPg9r3J/+AifkKPsHfQfWDv3zb5IyJLynZGdbXv/uiXgSqbbbL4mByBAD8ZJK09QLXUSEi9iCkaxxm/FoGPQtabiVM= 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: d81a024022ba11f1a21c59e7364eecb8-20260318 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:e4a61af1-c273-4b6a-aa28-fd672e785170,IP:0,U RL:0,TC:0,Content:-5,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:20 X-CID-META: VersionHash:89c9d04,CLOUDID:564890a783ef0e9feb79c896791cd2bf,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: d81a024022ba11f1a21c59e7364eecb8-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 1176601763; Wed, 18 Mar 2026 19:08:51 +0800 From: Li Jun To: chenhuacai@kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, lijun01@kylinos.cn Subject: [PATCH] Loongarch: env: fix missing NULL checks for kstrdup Date: Wed, 18 Mar 2026 19:08:48 +0800 Message-Id: <20260318110848.2779003-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" Fixes potential kernel oops during early boot when memory allocation fails while parsing CPU model from device tree. Signed-off-by: Li Jun --- arch/loongarch/kernel/env.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/loongarch/kernel/env.c b/arch/loongarch/kernel/env.c index 841206fde3ab..8d331e4f1c9a 100644 --- a/arch/loongarch/kernel/env.c +++ b/arch/loongarch/kernel/env.c @@ -49,6 +49,8 @@ static int __init init_cpu_fullname(void) ret =3D of_property_read_string(root, "model", &model); if (ret =3D=3D 0) { cpuname =3D kstrdup(model, GFP_KERNEL); + if (!cpuname) + return -ENOMEM; loongson_sysconf.cpuname =3D strsep(&cpuname, " "); } of_node_put(root); --=20 2.25.1