Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp826535imm; Wed, 26 Sep 2018 07:23:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV615wsR8haX/3Fkr1VEW+D34lGT/VL1KVq7/AeT1cwPmzoChzNK3wOcyZhnnr6BI2KXlvTbx X-Received: by 2002:a17:902:694a:: with SMTP id k10-v6mr6351965plt.166.1537971824403; Wed, 26 Sep 2018 07:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537971824; cv=none; d=google.com; s=arc-20160816; b=mi6wXGk+n7sgZ/tB4Y/mM2DCvZzK6Cgj+GEhkJaiMDjX99nRKbThwOo9fvYHt4q6QT 3Pse6CkiKbvpUuR7GEypmXFWwcy8J0hrJccAvjrQI7F3fT7bO1V9JQe1RkbSJxBmbJ2z lyfg+/plSU6RRAgXnrQT/LLgT1SCByCD6JvRNlGHX0zownQZnwQs/dMUPZBdFFXqclg7 VT3ALsEr6XrRB9GdeHyY8I5jdnMHy6w15Rg7o2hyFIEy9uq00CEsKLOaQ+jvZ4lraGfd kzifrQxM7lYtYC0IdBq7rfrSmggDuAdwNvyeFu6M7HigUVJUBvQemDJAxYcS+QPumjjr 81wA== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=6ON031UF+21wsM3bxMNuOYU15KIa2k/OsXTjqsw+aRE=; b=N6YtEWUw+o/IRoiQfngOl0crF6vpeoMY14BTAJmp/YiY1eRrv8EQG7F4qpTBLIOfGA VAT6ekOnoCBOEklxGxjooxmjpcOoDn5hsAzyBKeh9cCKTdW9LzLd+3ck3fjpGcM53otv xOUqnAA5iVbxt1SnDxmCqwNkm7Sp7cohaPNUux/t+FHXMRLhIgaxY+cKZMt7IvchQ94F JY1zwPRrV1A00JEb51NdKx5tr6Cqow7WoIwccokkm6FrS42gfecB5w8ZJaroIR8ZaEWa 7T/zf5xDx49bhbKdY348sCwE+J7wV3LLH97Z2GR2lH3OzrEOLrSVZ95BsbflgAF8mMrm J5Ew== 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 r23-v6si5249270pgi.409.2018.09.26.07.23.28; Wed, 26 Sep 2018 07:23:44 -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 S1727609AbeIZUfs (ORCPT + 99 others); Wed, 26 Sep 2018 16:35:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:52532 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726768AbeIZUfs (ORCPT ); Wed, 26 Sep 2018 16:35:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A60E1ACE1; Wed, 26 Sep 2018 14:22:35 +0000 (UTC) Date: Wed, 26 Sep 2018 16:22:32 +0200 From: Michal =?UTF-8?B?U3VjaMOhbmVr?= To: zhong jiang Cc: , , , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc: Move a dereference below a NULL test Message-ID: <20180926162232.250c0090@naga> In-Reply-To: <1537962368-14019-1-git-send-email-zhongjiang@huawei.com> References: <1537962368-14019-1-git-send-email-zhongjiang@huawei.com> X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks Michal