Skip to content

Commit

Permalink
Input: elants_i2c - detect enum overflow
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Randy Dunlap <[email protected]>
Signed-off-by: Josh Poimboeuf <[email protected]>
Reviewed-by: Michał Mirosław <[email protected]>
Link: https://lore.kernel.org/r/59e2e82d1e40df11ab38874c03556a31c6b2f484.1612974132.git.jpoimboe@redhat.com
Signed-off-by: Dmitry Torokhov <[email protected]>
jpoimboe authored and dtor committed Feb 16, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent a374c19 commit ede6747
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/input/touchscreen/elants_i2c.c
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit ede6747

Please sign in to comment.