[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210823123138.7ce66561a0d108bbdffb25ff@linux-foundation.org>
Date: Mon, 23 Aug 2021 12:31:38 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: CGEL <cgel.zte@...il.com>
Cc: "Gustavo A . R . Silva" <gustavoars@...nel.org>,
Sergei Trofimovich <slyfox@...too.org>,
linux-ia64@...r.kernel.org, linux-kernel@...r.kernel.org,
Jing Yangyang <jing.yangyang@....com.cn>,
Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH linux-next] arch/ia64/kernel/module.c: fix bugon.cocci
warnings
On Sun, 22 Aug 2021 18:51:10 -0700 CGEL <cgel.zte@...il.com> wrote:
> From: Jing Yangyang <jing.yangyang@....com.cn>
>
> Use BUG_ON instead of a if condition followed by BUG.
>
> Generated by: scripts/coccinelle/misc/bugon.cocci
>
> ...
>
> --- a/arch/ia64/kernel/module.c
> +++ b/arch/ia64/kernel/module.c
> @@ -560,8 +560,7 @@ struct plt_entry {
> while (plt->bundle[0][0]) {
> if (plt_target(plt) == target_ip)
> goto found;
> - if (++plt >= plt_end)
> - BUG();
> + BUG_ON(++plt >= plt_end);
There are concerns that there might be a config combination in which
BUG_ON() expands to a no-op. It this situation, `plt' won't get
incremented and we have a bug.
Now, we have taken care to prevent this from happening, via the
implementations of BUG_ON(). But still, mistakes happen and out of an
abundance of caution people avoid statements of the form
assert(expression-with-side-effects)
Powered by blists - more mailing lists