From: Paul Cercueil <paul@crapouillou.net>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH] pinctrl: ingenic: Make unreachable path more robust
Date: Fri, 14 Feb 2020 16:02:18 -0300 [thread overview]
Message-ID: <1581706938.3.5@crapouillou.net> (raw)
In-Reply-To: <73f0c9915473d9e4b3681fb5cc55144291a43192.1581698101.git.jpoimboe@redhat.com>
Hi Josh,
Le ven., févr. 14, 2020 at 10:37, Josh Poimboeuf <jpoimboe@redhat.com>
a écrit :
> In the second loop of ingenic_pinconf_set(), it annotates the switch
> default case as unreachable(). The annotation is technically correct,
> because that same case would have resulted in an early return in the
> previous loop.
>
> However, if a bug were to get introduced later, for example if an
> additional case were added to the first loop without adjusting the
> second loop, it would result in nasty undefined behavior: most likely
> the function's generated code would fall through to the next function.
>
> Another issue is that, while objtool normally understands
> unreachable()
> annotations, there's one special case where it doesn't: when the
> annotation occurs immediately after a 'ret' instruction. That happens
> to be the case here because unreachable() is immediately before the
> return.
>
> So change the unreachable() to BUG() so that the unreachable code, if
> ever executed, would panic instead of introducing undefined behavior.
> This also makes objtool happy.
I don't like the idea that you change this driver's code just to work
around a bug in objtool, and I don't like the idea of working around a
future bug that shouldn't be introduced in the first place.
-Paul
>
> This fixes the following objtool warning:
>
> drivers/pinctrl/pinctrl-ingenic.o: warning: objtool:
> ingenic_pinconf_set() falls through to next function
> ingenic_pinconf_group_set()
>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
> drivers/pinctrl/pinctrl-ingenic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-ingenic.c
> b/drivers/pinctrl/pinctrl-ingenic.c
> index 96f04d121ebd..6b61ac6cd4d2 100644
> --- a/drivers/pinctrl/pinctrl-ingenic.c
> +++ b/drivers/pinctrl/pinctrl-ingenic.c
> @@ -2158,7 +2158,7 @@ static int ingenic_pinconf_set(struct
> pinctrl_dev *pctldev, unsigned int pin,
> break;
>
> default:
> - unreachable();
> + BUG();
> }
> }
>
> --
> 2.21.1
>
next prev parent reply other threads:[~2020-02-14 19:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 16:37 [PATCH] pinctrl: ingenic: Make unreachable path more robust Josh Poimboeuf
2020-02-14 19:02 ` Paul Cercueil [this message]
2020-02-14 20:37 ` Josh Poimboeuf
2020-02-15 2:37 ` Paul Cercueil
2020-02-17 15:18 ` Josh Poimboeuf
2020-02-20 1:36 ` Paul Cercueil
2020-02-14 21:52 ` Randy Dunlap
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=1581706938.3.5@crapouillou.net \
--to=paul@crapouillou.net \
--cc=jpoimboe@redhat.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.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).