From: zhong jiang <zhongjiang@huawei.com>
To: <paulus@samba.org>, <benh@kernel.crashing.org>, <mpe@ellerman.id.au>
Cc: <linuxppc-dev@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] powerpc: Move a dereference below a NULL test
Date: Wed, 26 Sep 2018 19:46:08 +0800 [thread overview]
Message-ID: <1537962368-14019-1-git-send-email-zhongjiang@huawei.com> (raw)
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,
"cache level mismatch on lookup (got %d, expected %d)\n",
cache->level, level);
- if (!cache)
- cache = cache_do_one_devnode(node, level);
-
return cache;
}
--
1.7.12.4
next reply other threads:[~2018-09-26 11:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-26 11:46 zhong jiang [this message]
2018-09-26 13:58 ` [PATCH] powerpc: Move a dereference below a NULL test Christophe LEROY
2018-09-26 14:06 ` zhong jiang
2018-09-26 14:22 ` Michal Suchánek
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=1537962368-14019-1-git-send-email-zhongjiang@huawei.com \
--to=zhongjiang@huawei.com \
--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 \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).