All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michal Suchánek" <msuchanek@suse.de>
To: zhong jiang <zhongjiang@huawei.com>
Cc: <paulus@samba.org>, <benh@kernel.crashing.org>,
	<mpe@ellerman.id.au>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: Move a dereference below a NULL test
Date: Wed, 26 Sep 2018 16:22:32 +0200	[thread overview]
Message-ID: <20180926162232.250c0090@naga> (raw)
In-Reply-To: <1537962368-14019-1-git-send-email-zhongjiang@huawei.com>

On Wed, 26 Sep 2018 19:46:08 +0800
zhong jiang <zhongjiang@huawei.com> wrote:

> It is safe to move dereference below a NULL test.
> 
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  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

  parent reply	other threads:[~2018-09-26 14:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 11:46 [PATCH] powerpc: Move a dereference below a NULL test zhong jiang
2018-09-26 13:58 ` Christophe LEROY
2018-09-26 14:06   ` zhong jiang
2018-09-26 14:22 ` Michal Suchánek [this message]
2018-09-26 14:42   ` zhong jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180926162232.250c0090@naga \
    --to=msuchanek@suse.de \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=zhongjiang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.