From nobody Mon Jun 8 03:22:19 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 795B73D47AE for ; Tue, 2 Jun 2026 10:07:20 +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=1780394844; cv=none; b=B/5rRRLkNHp5Fg+D5xCY37v0ynO1uw6o/2zHdzF8zCc7sj3DI5z4L7PaL5F5uue2uxfTawfK9HJB2h/hDO8069aIV6xFn2VEmwalNtZ1bN/pq9audpZ7kcslUXb8/eov8ygjzxzhZ3d2S7kpZPmWjplg7FtrtITRWNmoedYlJn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780394844; c=relaxed/simple; bh=XniBDeQV+L3pFJ/PIrc7is7pqTDDM6IG1TM+Ru8iLWA=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=gAC6cyqvNISsVUEFahtvX1qz4f5Mew72iHyuAcsg0ELIzctDBCiUsFzUjBM74yCsK4T3K3GApMUBDIG3n2QlHYid1rHtZNN1/lGf4o/uLRN2+q2nrqUuRFGqBuKCnWZQ3MPvVPAFt6HoP0P8Tbq3dxfEG2V7AKOIYl2FDsT+Ql0= 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: d3bd63545e6a11f1aa26b74ffac11d73-20260602 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:d6e68acd-41db-406c-a2b1-2c3666b37e49,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:e7bac3a,CLOUDID:2dca1cd9fa739433b53cfeef45a7e8e9,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850|865|898,TC:nil,Content:0|15|50,E DM: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: d3bd63545e6a11f1aa26b74ffac11d73-20260602 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 11208078; Tue, 02 Jun 2026 18:07:13 +0800 From: Li Jun To: lijun01@kylinos.cn, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86: pmem: Add NULL check for platform_device_alloc Date: Tue, 2 Jun 2026 18:07:11 +0800 Message-Id: <20260602100711.2542568-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" Add proper error handling for the case when platform_device_alloc() returns NULL due to memory allocation failure. This prevents a potential NULL pointer dereference when trying to use the pdev pointer without checking if allocation succeeded. Signed-off-by: Li Jun --- arch/x86/kernel/pmem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/pmem.c b/arch/x86/kernel/pmem.c index 23154d24b117..04fb221716ff 100644 --- a/arch/x86/kernel/pmem.c +++ b/arch/x86/kernel/pmem.c @@ -27,6 +27,8 @@ static __init int register_e820_pmem(void) * simply here to trigger the module to load on demand. */ pdev =3D platform_device_alloc("e820_pmem", -1); + if (!pdev) + return -ENOMEM; =20 rc =3D platform_device_add(pdev); if (rc) --=20 2.25.1