[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210211021944.GA4933@qmqm.qmqm.pl>
Date: Thu, 11 Feb 2021 03:19:44 +0100
From: Michał Mirosław <mirq-linux@...e.qmqm.pl>
To: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>,
linux-kernel@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>,
linux-input@...r.kernel.org, Randy Dunlap <rdunlap@...radead.org>
Subject: Re: [PATCH RFC] input/elants_i2c: Detect enum overflow
On Wed, Feb 10, 2021 at 10:25:28AM -0600, Josh Poimboeuf wrote:
> If an enum value were to get added without updating this switch
> statement, the unreachable() annotation would trigger undefined
> behavior, causing execution to fall through the end of the function,
> into the next one.
>
> Make the error handling more robust for an unexpected enum value, by
> doing BUG() instead of unreachable().
>
> Fixes the following objtool warning:
>
> drivers/input/touchscreen/elants_i2c.o: warning: objtool: elants_i2c_initialize() falls through to next function elants_i2c_resume()
>
> Reported-by: Randy Dunlap <rdunlap@...radead.org>
> Acked-by: Randy Dunlap <rdunlap@...radead.org>
> Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
Reviewed-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
> ---
> drivers/input/touchscreen/elants_i2c.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index 6f57ec579f00..4c2b579f6c8b 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -656,8 +656,7 @@ static int elants_i2c_initialize(struct elants_data *ts)
> error = elants_i2c_query_ts_info_ektf(ts);
> break;
> default:
> - unreachable();
> - break;
> + BUG();
> }
>
> if (error)
> --
> 2.29.2
>
Powered by blists - more mailing lists