From patchwork Fri Mar 24 13:53:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 9642845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 571F060327 for ; Fri, 24 Mar 2017 13:54:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 453CE201BD for ; Fri, 24 Mar 2017 13:54:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38F6C27D29; Fri, 24 Mar 2017 13:54:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C44FA201BD for ; Fri, 24 Mar 2017 13:54:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=Aa05PICx6gArhcy5QqKx/TgSiKvE5Gh5nst+2AJc/kU=; b=pxH DsT2NAyC6rrhWcijXHwyTTN0GNK3bn6EiLNCk5gYcPC1snGGbNWD0V0WCj1qz6OvlBaqN/n9woOS/ eHoCowov7IXby5ymOy2/NblheBDwXDpsOUjKVflppHs77APgrIYnvUlpedhmCwc5HMw3X37y24Y5v zE9VEYbngi1hbbWd+JG63l+iXDjhNJcG+giFClB4inYbDcmo0AvS5tQuDfKsSIQuCHvTKR6+1lJNT c4YbqF70chntDxmJ569z6AX2z5/tHNkMUxnoh+Q+KEiHgyfxYopUPkZihhujsn4v3boYi4yY16apC RsfEm6/A7e3S+HUBC4cX93/3me96Dcw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1crPg8-0003rn-6U; Fri, 24 Mar 2017 13:54:56 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1crPg6-0003rL-2v for linux-arm-kernel@bombadil.infradead.org; Fri, 24 Mar 2017 13:54:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=R4egnnf9CUOwHpvqMnLumCTo2ePagvhj+5D4gcVvc3E=; b=CgVvs8Ceco1YDC7mNYMvIm62j tZv+Q/7OdMr4+nJnXfI1uSH7sGvUnxgXuT4FOAhXs3NKbh2P2VWV3ZEVFtJdUGh6MVIvilUpFYd/N 4ZFuP97C0JTOPtT7HcKb+5VS7FnD6UaX4PfShVlNDun/DfGZb7x5A6ZMFaXF/k+eQ+1dU2cJveKXs l7hc1K8qzM3QvTQjgN3a3HdsEdfZpIPtqb1mwlIFRsczhWV3evsNkLFchh7SbSmxlYq634vHAw1g3 a9CaN6ep2nebirRMnTx+MO5ifdNUjGuhsftnPeGew6Y7/rbZXSxym+0My4hS6d1xspHV6UBiOfy5p dbKtdwHaQ==; Received: from mx1.redhat.com ([209.132.183.28]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1crPg3-0007f5-83 for linux-arm-kernel@lists.infradead.org; Fri, 24 Mar 2017 13:54:52 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B403C009DEF; Fri, 24 Mar 2017 13:54:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3B403C009DEF Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=msalter@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3B403C009DEF Received: from t540.localdomain (ovpn-124-34.rdu2.redhat.com [10.10.124.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D14F8440A; Fri, 24 Mar 2017 13:53:59 +0000 (UTC) From: Mark Salter To: Will Deacon Subject: [PATCH] arm64: fix NULL dereference in have_cpu_die() Date: Fri, 24 Mar 2017 09:53:56 -0400 Message-Id: <20170324135356.25881-1-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 24 Mar 2017 13:54:00 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170324_135451_452948_D8E9AB51 X-CRM114-Status: GOOD ( 16.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Pratyush Anand , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 5c492c3f5255 ("arm64: smp: Add function to determine if cpus are stuck in the kernel") added a helper function to determine if die() is supported in cpu_ops. This function assumes a cpu will have a valid cpu_ops entry, but that may not be the case for cpu0 is spin-table or parking protocol is used to boot secondary cpus. In that case, there is a NULL dereference if have_cpu_die() is called by cpu0. So add a check for a valid cpu_ops before dereferencing it. Fixes: 5c492c3f5255 ("arm64: smp: Add function to determine if cpus are stuck in the kernel") Signed-off-by: Mark Salter --- arch/arm64/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ef1caae..9b10365 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -944,7 +944,7 @@ static bool have_cpu_die(void) #ifdef CONFIG_HOTPLUG_CPU int any_cpu = raw_smp_processor_id(); - if (cpu_ops[any_cpu]->cpu_die) + if (cpu_ops[any_cpu] && cpu_ops[any_cpu]->cpu_die) return true; #endif return false;