summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorNathan Chancellor <nathan@kernel.org>2024-10-15 12:23:47 -0700
committerJiri Kosina <jkosina@suse.com>2024-10-16 10:15:50 +0200
commitb2b8a75e1d88c551a0b30d44d0be552210219eea (patch)
treef6e4af0b3a21912f32e9361bcd2657acefab21ce /drivers/hid
parentaa68d2bd9befe8615852b0ab41b3bd5abeae0979 (diff)
HID: Remove default case statement in fetch_item()
A default case statement with a bare unreachable() was recently added to fetch_item(), which by itself introduces undefined behavior. objtool points this out with a few different warnings, depending on configuration and compiler: vmlinux.o: warning: objtool: fetch_item() falls through to next function ... vmlinux.o: warning: objtool: hid_open_report() falls through to next function hid_parser_main() vmlinux.o: warning: objtool: hid_scan_report() falls through to next function hid_allocate_device() vmlinux.o: warning: objtool: hid_open_report+0x21b: can't find jump dest instruction at .text.hid_open_report+0x40f Replacing unreachable() with BUG() is a typical fix to eliminate the undefined behavior and make the default case well defined. However, in this case, all possible values are enumerated in the switch statement, so the default case can never actually happen, as proven with the comment next to the item->size assignment. Just remove the default case altogether, as the return statement would still be valid if the switch statement were ever to be skipped. Fixes: 61595012f280 ("HID: simplify code in fetch_item()") Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Closes: https://lore.kernel.org/20241010222451.GA3571761@thelio-3990X/ Reported-by: Paul E. McKenney <paulmck@kernel.org> Closes: https://lore.kernel.org/fe8c909e-bf02-4466-b3eb-0a4747df32e3@paulmck-laptop/ Tested-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Jiri Kosina <jkosina@suse.com>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-core.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 87b2cdd7f0c4..bdd19bce11eb 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -802,9 +802,6 @@ static const u8 *fetch_item(const __u8 *start, const __u8 *end, struct hid_item
case 4:
item->data.u32 = get_unaligned_le32(start);
break;
-
- default:
- unreachable();
}
return start + item->size;