Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5387822imm; Sun, 22 Jul 2018 21:21:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpckP7C1fLUOkN+S37U+U6OdRsuBbIybGJf3XYBTKdsi40HvA+NShrgEA/TuXm8wUWY+u+CE X-Received: by 2002:a63:4a07:: with SMTP id x7-v6mr10787436pga.34.1532319708159; Sun, 22 Jul 2018 21:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532319708; cv=none; d=google.com; s=arc-20160816; b=dzqzwJYfVsaJAnS4nVzHrKYIkvL/M8KDf8dapV3WkvUmosenb+Gy/hoQq7z8XPsXrf xgfUSMkmDgdDgNGPeeIxgLFCOAaNrYI/kd+INZmC1W9dRvJMnjIOVtIrBcHvVjSEDhVX kwpzUjChxL3tL7oxTrBjkcqQVxFBRYwJ58hyM6PWxmGbmoQd1PzL9MnspDIgTX0LXP6u Dw5VDEDJ9eZjZCEtJx0mwP0nKjvPsG/1HH9JnEdfQgIUlbMEHQV1stTdhfLrV1ZK9tjN xTSOsrjzl4D+a6UEluhbhU6ajiRMhr6ftVAq3o15S98Baq0/MNDVQsFhq+Rb1IER+fk8 r7Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=TvrUFLizM1O7wJpP+xLQwQJHjCWjf/6z3twTugvyIE8=; b=OBUrLUXhA/H439Ezwir5hfbM67+/IHGbYjbgLjXYh7ZM5XXD9hRs5e+rmg+6+kn7Rj L2JoWRQYci60hTTwUh6TzSayKtQO9lx+ckjrg7X6sQTATuKbrtn8Ju32ibKsYQmwRgOv m0vYqpCOG9WWuarsi+9qBi5GOCoOIJ7S+30ptp4Gux6i56usZqSziZ4Kk/YsU35pKIOQ leBaTAEOMQWbtVdY/23WOSgf1L06WHimqceLW1C+NlpwoBp1SRRv42vTknr9vC3BzjGF QmZof44iHt0IjTJjNmvZY24kGuG7UZ6yKyDZSLN09p5aa+CeKyz9ldmRspf7yP/vhucq 15fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20-v6si7403756pgb.92.2018.07.22.21.21.33; Sun, 22 Jul 2018 21:21:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728059AbeGWFTx (ORCPT + 99 others); Mon, 23 Jul 2018 01:19:53 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:14052 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbeGWFTx (ORCPT ); Mon, 23 Jul 2018 01:19:53 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 8835A15ADD7795D3C508; Mon, 23 Jul 2018 12:20:36 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w6N4KPek046097; Mon, 23 Jul 2018 12:20:25 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018072312202698-1250143 ; Mon, 23 Jul 2018 12:20:26 +0800 From: Yi Wang To: mingo@redhat.com Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, jiang.biao2@zte.com.cn, wang.yi59@zte.com.cn, zhong.weidong@zte.com.cn Subject: [PATCH] sched/topology: check variable group before dereferenced Date: Mon, 23 Jul 2018 12:19:07 +0800 Message-Id: <1532319547-33335-1-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-07-23 12:20:27, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-07-23 12:20:25, Serialize complete at 2018-07-23 12:20:25 X-MAIL: mse01.zte.com.cn w6N4KPek046097 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The variable group in sched_domain_debug_one() is not checked when firstly used in cpumask_test_cpu(cpu, sched_group_span(group)), but it maybe NULL(checked later in the following while loop) and may cause NULL pointer dereference without checking. We need to check it before using to avoid NULL dereference. Signed-off-by: Yi Wang Reviewed-by: Jiang Biao --- kernel/sched/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 5ac724b..c7cf87c 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -53,7 +53,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, printk(KERN_ERR "ERROR: domain->span does not contain " "CPU%d\n", cpu); } - if (!cpumask_test_cpu(cpu, sched_group_span(group))) { + if (group && !cpumask_test_cpu(cpu, sched_group_span(group))) { printk(KERN_ERR "ERROR: domain->groups does not contain" " CPU%d\n", cpu); } -- 1.8.3.1