Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp857246imm; Wed, 25 Jul 2018 07:22:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcHbE/1I73wl/E9yRPqQStqHo8XCJAfNJ1UqQAadIOEaupT8aHY+dPdK5wm10aZWovfVH8g X-Received: by 2002:a63:5c10:: with SMTP id q16-v6mr5646750pgb.452.1532528541389; Wed, 25 Jul 2018 07:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532528541; cv=none; d=google.com; s=arc-20160816; b=Pl9Yi+4/aAkMpX7Qo2/zxpVY1gxPnUXlaSWRYAUXF5fo0qiUOMmw4bbfK5M5u+QAZA S3+BhiLpOXWsH80mjoQ9uzD3hIbE/ldO86zLLZLfo3oaoiISmqZnk0VI6CINTi7V9RgW G8q+FNXTkVkdSK5VcCFGhVJq5lflfER7fbJrmgZr7i7fXQ4t0q0XHk6InBxUvtBrNXtD M0gRvfRobxsV5W09VTm0uSdHGnd0dnZCkn33GYTfgteoi9xsmKXANoM46YDdqyj5EA4H jAtbebb8+oIM/WVImlt86T/OTGi2SM4A0NTq/QxtUXr3dxOS8/g6NCEDjmXyFBtaST7a +lYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=/wC6ZfEGX+M7ElxN2Mth/Tizrpf4DYrhxktuS/fln38=; b=CFlAi5kmQfVaU9FN/wTw+m8EZrFx37y3TnPr3JlgoNGX3K2txRlosY8v2XJU3gNd43 ZETRrAHOJyCByIhDX6HPzr8jSaOCSoaLqDwPnti0tjiiTJx2ZF3a2UNeTVRZSzX3jn8r pJJtZydMGjcBn+D2Fr9t6nzkNqeTeaJydG68C7cud1Cgf3Vnr9zYYenKBtGk3l5BGdh8 kZbO4CTKQ1qgDXzUQZjlGxdpLQE3h94c5+ebSoGysFHcUX5JetOMj0oVylRYSWtNUoLd wxeC2bIFWvrvQQjkwMyIlZBv7emHgmidNW4NTbn6O4TeuYKQW1KOBZlaGJSYobT25KgI ctZQ== 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 b18-v6si14253139pge.666.2018.07.25.07.22.06; Wed, 25 Jul 2018 07:22:21 -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 S1729352AbeGYPcu (ORCPT + 99 others); Wed, 25 Jul 2018 11:32:50 -0400 Received: from terminus.zytor.com ([198.137.202.136]:52979 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727881AbeGYPcu (ORCPT ); Wed, 25 Jul 2018 11:32:50 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6PEKavt399926 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 25 Jul 2018 07:20:36 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6PEKZ0g399923; Wed, 25 Jul 2018 07:20:35 -0700 Date: Wed, 25 Jul 2018 07:20:35 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Yi Wang Message-ID: Cc: mingo@kernel.org, tglx@linutronix.de, jiang.biao2@zte.com.cn, peterz@infradead.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, wang.yi59@zte.com.cn, hpa@zytor.com Reply-To: hpa@zytor.com, wang.yi59@zte.com.cn, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, jiang.biao2@zte.com.cn, peterz@infradead.org, mingo@kernel.org, tglx@linutronix.de In-Reply-To: <1532319547-33335-1-git-send-email-wang.yi59@zte.com.cn> References: <1532319547-33335-1-git-send-email-wang.yi59@zte.com.cn> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/topology: Check variable group before dereferencing it Git-Commit-ID: 6cd0c583b04b2bd9415e07b51b63ab799949dd66 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_48_96 autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6cd0c583b04b2bd9415e07b51b63ab799949dd66 Gitweb: https://git.kernel.org/tip/6cd0c583b04b2bd9415e07b51b63ab799949dd66 Author: Yi Wang AuthorDate: Mon, 23 Jul 2018 12:19:07 +0800 Committer: Ingo Molnar CommitDate: Wed, 25 Jul 2018 11:25:07 +0200 sched/topology: Check variable group before dereferencing it The 'group' variable in sched_domain_debug_one() is not checked when firstly used in cpumask_test_cpu(cpu, sched_group_span(group)), but it might be NULL (it is checked later in the following while loop) and may cause NULL pointer dereference. We need to check it before using to avoid NULL dereference. Signed-off-by: Yi Wang Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Jiang Biao Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: zhong.weidong@zte.com.cn Link: http://lkml.kernel.org/r/1532319547-33335-1-git-send-email-wang.yi59@zte.com.cn Signed-off-by: Ingo Molnar --- 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 05a831427bc7..56a0fed30c0a 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -47,7 +47,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) { 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); }