From nobody Wed Apr 24 22:25:28 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0B23C433EF for ; Wed, 18 May 2022 08:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233178AbiERI3f (ORCPT ); Wed, 18 May 2022 04:29:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233040AbiERI3b (ORCPT ); Wed, 18 May 2022 04:29:31 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2845131F1F for ; Wed, 18 May 2022 01:29:28 -0700 (PDT) Received: from kwepemi100004.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L35jv2j3MzgZ08; Wed, 18 May 2022 16:28:51 +0800 (CST) Received: from kwepemm600010.china.huawei.com (7.193.23.86) by kwepemi100004.china.huawei.com (7.221.188.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 18 May 2022 16:29:26 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600010.china.huawei.com (7.193.23.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 18 May 2022 16:29:26 +0800 From: Chao Liu To: , CC: , Subject: [PATCH] cpu/hotplug: check the return value of idle_thread_get Date: Mon, 27 Mar 2023 20:37:28 +0000 Message-ID: <20230327203728.159123-1-liuchao173@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600010.china.huawei.com (7.193.23.86) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" ilde may be ERR_PTR() Signed-off-by: Chao Liu --- kernel/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index d0a9aa0b42e8..8ddf372e8d29 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -590,6 +590,9 @@ static int bringup_cpu(unsigned int cpu) struct task_struct *idle =3D idle_thread_get(cpu); int ret; =20 + if (IS_ERR(idle)) + return PTR_ERR(idle); + /* * Reset stale stack state from the last time this CPU was online. */ @@ -614,7 +617,12 @@ static int bringup_cpu(unsigned int cpu) static int finish_cpu(unsigned int cpu) { struct task_struct *idle =3D idle_thread_get(cpu); - struct mm_struct *mm =3D idle->active_mm; + struct mm_struct *mm =3D NULL; + + if (IS_ERR(idle)) + return PTR_ERR(idle); + + mm =3D idle->active_mm; =20 /* * idle_task_exit() will have switched to &init_mm, now --=20 2.23.0