Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751440AbdFBHcN (ORCPT ); Fri, 2 Jun 2017 03:32:13 -0400 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:33832 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751176AbdFBHcK (ORCPT ); Fri, 2 Jun 2017 03:32:10 -0400 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 165.244.249.23 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: , CC: , , , Subject: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu() Date: Fri, 2 Jun 2017 16:31:03 +0900 Message-ID: <1496388663-29067-2-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1496388663-29067-1-git-send-email-byungchul.park@lge.com> References: <1496388663-29067-1-git-send-email-byungchul.park@lge.com> X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB01/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/06/02 16:31:10, Serialize by Router on LGEKRMHUB01/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/06/02 16:31:10, Serialize complete at 2017/06/02 16:31:10 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 735 Lines: 24 When the heap tree is empty, cp->elements[0].cpu has meaningless value. We need to consider the case. Signed-off-by: Byungchul Park --- kernel/sched/cpudeadline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index d4a6963..9b314a9 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -110,7 +110,8 @@ static void cpudl_heapify(struct cpudl *cp, int idx) static inline int cpudl_maximum_cpu(struct cpudl *cp) { - return cp->elements[0].cpu; + int cpu = cp->elements[0].cpu; + return cp->elements[cpu].idx == IDX_INVALID ? -1 : cpu; } static inline u64 cpudl_maximum_dl(struct cpudl *cp) -- 1.9.1