]> git.baikalelectronics.ru Git - kernel.git/commit
Input: elants_i2c - detect enum overflow
authorJosh Poimboeuf <jpoimboe@redhat.com>
Thu, 11 Feb 2021 20:50:37 +0000 (12:50 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 16 Feb 2021 21:08:50 +0000 (13:08 -0800)
commit9cf36f6b080c5f4d3d7813269d185bd9b879c4c1
tree73d4f2830f962d4900e41590cb1ecee0d2968013
parenta01c57250edec75c4e18a61ccdbc53c3eaf28abf
Input: elants_i2c - detect enum overflow

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@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/59e2e82d1e40df11ab38874c03556a31c6b2f484.1612974132.git.jpoimboe@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/elants_i2c.c