Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp850138imm; Wed, 26 Sep 2018 07:45:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Utd3EF5wwaXVkuwcet9zBIXh4ZsEsfE0esJgfTcjwtj6kIdXtjQMs+oI8kgDgsvDNh8tI X-Received: by 2002:a63:4425:: with SMTP id r37-v6mr6000482pga.391.1537973100891; Wed, 26 Sep 2018 07:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537973100; cv=none; d=google.com; s=arc-20160816; b=VNWVrlWc0AJPFrjnxpMWg+13M94Vfb3COLaZW1AaLAnMwp4VN0Y59bMX9aGl4n4u8+ 0KgODj9XlQn9uCreibolWWpMZBnoiecIl8VtdNNPIeB/2j9syQQpKLwx2O2jY1BiRp3S 2mAxMU3drYo55Z9TwhT54STfsInnS499f/Ne70y87kY9iig2P1bhT/oybElxCyXHbiLd n++bIfmQ2FBdrAqvrUNz0o9ZzPrndpIelD+0MBW86sNGheO0J4MWHQOfzct+3TtOkVrt cQ3I6hYByc+tNY/BtljhBI3sKgQPvNSu1SZGrA+MgU/NXeyOGR9a4bZPAEfonH1wDEnt X5nw== 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=+AJBi1fwyMgEAb7jjjVRdMeNwiHP5Pr50J6OGQhmiKY=; b=v7w1z/DE0HbJDoAGSGcNOdgCsz4WoweFKn39xNHhQHZmODBGX9mKXHY4O572YOXjqJ edezi6kJgyUL0d08I2uqGnPWrF1pxd6frGF+ob501eLIfoR0KcSOxySEbpO1/wT/5o7X ftR4nvQS8mp2tL7t4dbGf5DeNbUfsYkGBMz+r/6SPK1ZEMF6uXyyc+JwHeWNqo5vH1Lv 1SzdlMSyKQPs/qw4MM+t9nGK6dRTjqq+raji3Grvao0Jk3WXqQt6LNnjpvWYc8lgfWc4 +PL456Pz+6Vl+zTpG6kcqe2R+HBAGQv6/R3XT4G3oOd8IAVkBTdagNS5IYp/WiDo3q46 RvXg== 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.44.45; Wed, 26 Sep 2018 07:45:00 -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 S1727845AbeIZUzq (ORCPT + 99 others); Wed, 26 Sep 2018 16:55:46 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:53333 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727048AbeIZUzq (ORCPT ); Wed, 26 Sep 2018 16:55:46 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 64A0D77B56CA4; Wed, 26 Sep 2018 22:42:25 +0800 (CST) Received: from [127.0.0.1] (10.177.29.68) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.399.0; Wed, 26 Sep 2018 22:42:24 +0800 Message-ID: <5BAB9ACF.6040102@huawei.com> Date: Wed, 26 Sep 2018 22:42:23 +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: =?ISO-8859-1?Q?Michal_Such=E1nek?= CC: , , , , Subject: Re: [PATCH] powerpc: Move a dereference below a NULL test References: <1537962368-14019-1-git-send-email-zhongjiang@huawei.com> <20180926162232.250c0090@naga> In-Reply-To: <20180926162232.250c0090@naga> Content-Type: text/plain; charset="ISO-8859-1" 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 22:22, Michal Such?nek wrote: > On Wed, 26 Sep 2018 19:46:08 +0800 > zhong jiang wrote: > >> 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, > This has also null test so cache should be dereferenced only when > non-null here. :-[ , you're right. I forget WARN_ONCE. please ignore the patch. Sincerely, zhong jiang > Thanks > > Michal > > . >