Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp657908imm; Wed, 26 Sep 2018 04:59:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV60JHhlMdWeW9O0NUzmZwCpAJSpjAQdqtvUgnF6mKO74cWTqFhUuRmPr9JIn8Iny9caJtUBD X-Received: by 2002:a65:42c2:: with SMTP id l2-v6mr266859pgp.139.1537963148302; Wed, 26 Sep 2018 04:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537963148; cv=none; d=google.com; s=arc-20160816; b=aHFeFqX90t2OOC1ISZFDzsL7aM6wJL8ndjOfqpHxjRb5rqm4B/I+m8QtVAhSp+xuyI T3SUYuGwd6zdXSL9WooSfAC2O/Cn285cliIVyaRefIiLvqh5u/c083oeN5LaTnJQV3Zj Q+RA0kMCjwQ+7QJmCeVG0h8GQl2Iw0Swz2AyL9IUn0AkyBbhjOqFR+EgoNXeYjM5kFOO xxuDLPUhY0bkMA8bsdJBxRvPAWjQdAyMrddBC4oCGllx/2BOYljnq269JDkbkuLY2TPB J14/jF4fqlsNQtlUdF5VKWn7IjshpaWMnbwDcjC8s+pIq76Ekr+FOE9sq5HN9PectCPi 4gKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=7QwBmY/Fq5Uquf6OyAkLTLm5Wh71eLhxHpQOL3E6n6Q=; b=vP4+nd+dk3gn64/JcX06cXEG1lwmmitjIt285yeF7ACmaMq5LB/TNJ/Lt52TvFwMSg aRW5+lTzCGlO7z6WvunAzm1XdEUztvDTNQu4Ow0ZxRL0yr/aNBUTHKN4LUO/XPe032ry rjvfw9vhH8iCvatDGX0LM27JW4PwJjy2sRC8vbAgx0iIyFcRKboGxKtOmEvuU/kCxgP9 QLh9qdagXmBPRTczs6yubslVZ/aUfIQG6i/+Eqm+h0bOtilMIyG/M9CvPZpyagxACb68 y4vfrWEdkwfzIP8PwsJR5X3jslqjZylxJswkth7l6k3mPj91LtRo/Xqc5Q1wva0T5mSW rq2Q== 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 f29-v6si4990083pgl.570.2018.09.26.04.58.53; Wed, 26 Sep 2018 04:59:08 -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 S1728271AbeIZSLW (ORCPT + 99 others); Wed, 26 Sep 2018 14:11:22 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13126 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727201AbeIZSLW (ORCPT ); Wed, 26 Sep 2018 14:11:22 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B0CD892B182AD; Wed, 26 Sep 2018 19:58:39 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.399.0; Wed, 26 Sep 2018 19:58:35 +0800 From: zhong jiang To: , , CC: , Subject: [PATCH] powerpc: Move a dereference below a NULL test Date: Wed, 26 Sep 2018 19:46:08 +0800 Message-ID: <1537962368-14019-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is safe to move dereference below a NULL test. Signed-off-by: zhong jiang --- arch/powerpc/kernel/cacheinfo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c index a8f20e5..7f19714 100644 --- a/arch/powerpc/kernel/cacheinfo.c +++ b/arch/powerpc/kernel/cacheinfo.c @@ -401,14 +401,13 @@ static struct cache *cache_lookup_or_instantiate(struct device_node *node, struct cache *cache; cache = cache_lookup_by_node(node); + if (!cache) + cache = cache_do_one_devnode(node, level); WARN_ONCE(cache && cache->level != level, "cache level mismatch on lookup (got %d, expected %d)\n", cache->level, level); - if (!cache) - cache = cache_do_one_devnode(node, level); - return cache; } -- 1.7.12.4