Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp796380imm; Wed, 26 Sep 2018 07:00:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV63nMQo/wS/Cnbv2Z7edluBuAgVbUOoTvm5bdwJNAdRQbMC9s5eCfPrkCZJbwnczZdIY0O8J X-Received: by 2002:a17:902:1121:: with SMTP id d30-v6mr6138393pla.250.1537970411344; Wed, 26 Sep 2018 07:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537970411; cv=none; d=google.com; s=arc-20160816; b=vNHczzM2whUmmfkEmZN40X5J62RvIjaCB8yCaqOUHMonw6jYu5UQPy/rw4N3AWeoax ss/IJLAlfA0rh/Ky5XUL7L3tGbkc42aHcBlUMdbU7VYzsY2cynuGI2298fSB2lt3KzTb vC2SvJDe/PP3Vw1oGQchVL0lNtzXjWUYFBik3mnNJEiEa1e6y3n868yH70yXjOMLK4vf 9pUNMu9yjYuRA6dTyLP7vLKOlkfuZt2vtk+UqVbM1jOm3Z5NmbMvvGVLX9SoXUJkktL0 A7gb/HJc5cz6abFtSufetijRuEADNPevImrlMz0wTLE1Ts87RcRytOL266+1a91hr7tX dpPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=VvY9FOvdnd8BxJvy+teBc5vUOSGohsmpU62fm77IYR4=; b=m8rVXl9tqHWIuS8Som0aRbOh3R0hKu4+kYqJfbTR9j9kgB9WwoNsuQM+ev4KV5ggVP HYr8u/CpW/gZNZ42IxMoBsZk1aboyCh8N6s7l4DEUEBzk9HZmhENg3JgP4MNv43+zmpH lv4vZ4mDqumW98Ss0xJ8/SUfoiCxNWRRv8FLDbQXSVqPeb61Qt8xxxthdzHVGf4yBv0B 0zlu3UH1VDpcarNgzTMQD6FKEBj0AdmT7MII+cblmpXkmYCn6HuacDZ+KnEc5FJT6fW4 CMgK8V2gVWvihR/n0s8Haptcvd1s6r/o4lZEjQGh+qN6LBKYTsHrxPRzJDuD3XYiPtY6 6E2A== 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 b7-v6si5150828pfm.93.2018.09.26.06.59.55; Wed, 26 Sep 2018 07:00:11 -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 S1728142AbeIZUL4 (ORCPT + 99 others); Wed, 26 Sep 2018 16:11:56 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:40472 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726937AbeIZUL4 (ORCPT ); Wed, 26 Sep 2018 16:11:56 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 42L00S6PV6z9ttfr; Wed, 26 Sep 2018 15:58:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id XzXnEebpN7Lz; Wed, 26 Sep 2018 15:58:48 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 42L00S5kY8z9ttfn; Wed, 26 Sep 2018 15:58:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 525B78B817; Wed, 26 Sep 2018 15:58:49 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id uIZE3cJYrG0Z; Wed, 26 Sep 2018 15:58:49 +0200 (CEST) Received: from PO15451 (unknown [172.25.231.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2C3E98B803; Wed, 26 Sep 2018 15:58:49 +0200 (CEST) Subject: Re: [PATCH] powerpc: Move a dereference below a NULL test To: zhong jiang , paulus@samba.org, benh@kernel.crashing.org, mpe@ellerman.id.au Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <1537962368-14019-1-git-send-email-zhongjiang@huawei.com> From: Christophe LEROY Message-ID: Date: Wed, 26 Sep 2018 15:58:48 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1537962368-14019-1-git-send-email-zhongjiang@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 26/09/2018 à 13:46, zhong jiang a écrit : > 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); But by doing this, you change the meaning of the following warning. Is that what you want ? In that case the text of the WARN_ONCE() should be changed, because the mismatch is not only on lookup now. Christophe > > 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; > } > >