Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp805779imm; Wed, 26 Sep 2018 07:06:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV63pwTJtjuHa8OEPlllYRnngqFk/50YQ5NV+wpFb/lh8sdZ4nE6PlLuqkBh64JoU098nn0R8 X-Received: by 2002:a62:6b41:: with SMTP id g62-v6mr6580245pfc.113.1537970816989; Wed, 26 Sep 2018 07:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537970816; cv=none; d=google.com; s=arc-20160816; b=Wwr3wspLaKaf/km/2kh9EXZTudoyd5WyUDmxCj1bDx1jgiurvKr1ACOK3P+VsE/e1D yTrXJf+7n+IlLQXJ+DIJdjNaxnukDmHhbWx5kEkVDPWemak9ZZ0WvobpyS7A2Klmd3LF zE3bXJgh3UjjPNAvI+5x/wo3VGNaVQgXkDaVYVv64+sK8g8sFa7CX/gPI/bVk0asMPCI IoK1tWNXhnhZjVehse3uQhTj5RPPUV7izc8yJBngI/REEV4EewY/kP6V3vFf/3F2A2yH l8FdG3tghdzoLlyaVHrNw0Xzvj3KwO18yIGlLw4oq+AtQnfYddV3EmPX3jJEtmzB7VMK SW3A== 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:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=z5dypUTRY1XYmmTVvGmcknFUFNZ7X8G2W+63IDPEEWw=; b=EN+/I1gw9aro3jzhEMfq0SDhR2yIeqp5eq1G6L6bZ20KpaWQy4iy4ob9Yhr2vtcB02 kLdgIuVxNcgJxhcrh8Df7em/Ea0Fi3Zg8Lm37y8UOq9S7jWL7SdLmWdyzwy74jSBLVGt uYa72yaicuCLMQYP7ch58F8n0lvaR1STRP91TW6ARxCvG9KgirppwxZQLYEaGAn36YvN s83XH7xnXQVNEF2dtwGXj6xO1lBKAOpprcDYjU3hcbkIOixGFXyUqGs7mTEvDpSJ7heq ruoS8OnsfGwUufGU2+8sRBqHfeI5tks17zclfn0h55YjYOTpA+HQY+T+q13EwQ6k7RFC ldyw== 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 o7-v6si5308092pls.344.2018.09.26.07.06.39; Wed, 26 Sep 2018 07:06:56 -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 S1727356AbeIZUTi (ORCPT + 99 others); Wed, 26 Sep 2018 16:19:38 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51124 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726994AbeIZUTh (ORCPT ); Wed, 26 Sep 2018 16:19:37 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 24CCDF61F32AA; Wed, 26 Sep 2018 22:06:26 +0800 (CST) Received: from [127.0.0.1] (10.177.29.68) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Wed, 26 Sep 2018 22:06:22 +0800 Message-ID: <5BAB925D.1030803@huawei.com> Date: Wed, 26 Sep 2018 22:06:21 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Christophe LEROY CC: , , , , Subject: Re: [PATCH] powerpc: Move a dereference below a NULL test References: <1537962368-14019-1-git-send-email-zhongjiang@huawei.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.29.68] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/9/26 21:58, Christophe LEROY wrote: > > > 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. > Yep, I forget the WARN_ONCE. I think we should just remove it. Thought? Thanks, zhong jiang > 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; >> } >> > > . >