CC: [email protected] CC: [email protected] In-Reply-To: <[email protected]> References: <[email protected]> TO: Benjamin Tissoires <[email protected]> TO: Jiri Kosina <[email protected]> TO: Dmitry Torokhov <[email protected]> TO: Jonathan Corbet <[email protected]> TO: "Ahelenia ZiemiaĆska" <[email protected]> TO: Ping Cheng <[email protected]> TO: Aaron Armstrong Skomra <[email protected]> TO: Jason Gerecke <[email protected]> TO: Peter Hutterer <[email protected]> CC: [email protected] CC: [email protected]
Hi Benjamin, I love your patch! Perhaps something to improve: [auto build test WARNING on hid/for-next] [also build test WARNING on v5.17-rc1 next-20220128] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Benjamin-Tissoires/HID-fix-for-generic-input-processing/20220127-002107 base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next :::::: branch date: 3 days ago :::::: commit date: 3 days ago config: riscv-randconfig-c006-20220124 (https://download.01.org/0day-ci/archive/20220130/[email protected]/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 2a1b7aa016c0f4b5598806205bdfbab1ea2d92c4) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install riscv cross compiling tool for clang build # apt-get install binutils-riscv64-linux-gnu # https://github.com/0day-ci/linux/commit/5f297c23cba491924689834a01ef511263c9e547 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Benjamin-Tissoires/HID-fix-for-generic-input-processing/20220127-002107 git checkout 5f297c23cba491924689834a01ef511263c9e547 # save the config file to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> clang-analyzer warnings: (new ones prefixed by >>) ^~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:2353:2: note: Taking false branch if (hdev->ll_driver->request) ^ drivers/hid/hid-core.c:2356:2: note: Calling '__hid_request' __hid_request(hdev, report, reqtype); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1931:6: note: Assuming 'buf' is non-null if (!buf) ^~~~ drivers/hid/hid-core.c:1931:2: note: Taking false branch if (!buf) ^ drivers/hid/hid-core.c:1936:6: note: Assuming 'reqtype' is equal to HID_REQ_SET_REPORT if (reqtype == HID_REQ_SET_REPORT) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1936:2: note: Taking true branch if (reqtype == HID_REQ_SET_REPORT) ^ drivers/hid/hid-core.c:1937:3: note: Calling 'hid_output_report' hid_output_report(report, buf); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1844:14: note: Field 'id' is <= 0 if (report->id > 0) ^ drivers/hid/hid-core.c:1844:2: note: Taking false branch if (report->id > 0) ^ drivers/hid/hid-core.c:1848:14: note: Assuming 'n' is < field 'maxfield' for (n = 0; n < report->maxfield; n++) ^~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1848:2: note: Loop condition is true. Entering loop body for (n = 0; n < report->maxfield; n++) ^ drivers/hid/hid-core.c:1849:3: note: Calling 'hid_output_field' hid_output_field(report->device, report->field[n], data); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1811:2: note: 'size' initialized here unsigned size = field->report_size; ^~~~~~~~~~~~~ drivers/hid/hid-core.c:1814:14: note: Assuming 'n' is < 'count' for (n = 0; n < count; n++) { ^~~~~~~~~ drivers/hid/hid-core.c:1814:2: note: Loop condition is true. Entering loop body for (n = 0; n < count; n++) { ^ drivers/hid/hid-core.c:1815:7: note: Assuming field 'logical_minimum' is < 0 if (field->logical_minimum < 0) /* signed values */ ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1815:3: note: Taking true branch if (field->logical_minimum < 0) /* signed values */ ^ drivers/hid/hid-core.c:1816:4: note: Calling 'implement' implement(hid, data, offset + n * size, size, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1426:15: note: Assuming 'n' is <= 32 if (unlikely(n > 32)) { ^ include/linux/compiler.h:78:42: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ drivers/hid/hid-core.c:1426:2: note: Taking false branch if (unlikely(n > 32)) { ^ drivers/hid/hid-core.c:1430:13: note: Assuming 'n' is >= 32 } else if (n < 32) { ^~~~~~ drivers/hid/hid-core.c:1430:9: note: Taking false branch } else if (n < 32) { ^ drivers/hid/hid-core.c:1816:4: note: Returning from 'implement' implement(hid, data, offset + n * size, size, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1814:14: note: Assuming 'n' is < 'count' for (n = 0; n < count; n++) { ^~~~~~~~~ drivers/hid/hid-core.c:1814:2: note: Loop condition is true. Entering loop body for (n = 0; n < count; n++) { ^ drivers/hid/hid-core.c:1815:14: note: Field 'logical_minimum' is < 0 if (field->logical_minimum < 0) /* signed values */ ^ drivers/hid/hid-core.c:1815:3: note: Taking true branch if (field->logical_minimum < 0) /* signed values */ ^ drivers/hid/hid-core.c:1817:31: note: Passing the value 32 via 2nd parameter 'n' s32ton(field->value[n], size)); ^~~~ drivers/hid/hid-core.c:1817:7: note: Calling 's32ton' s32ton(field->value[n], size)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1339:6: note: Assuming 'a' is 0 if (a && a != -1) ^ drivers/hid/hid-core.c:1339:8: note: Left side of '&&' is false if (a && a != -1) ^ drivers/hid/hid-core.c:1341:21: note: The result of the left shift is undefined due to shifting by '32', which is greater or equal to the width of type 'int' return value & ((1 << n) - 1); ^ ~ >> drivers/hid/hid-core.c:1665:30: warning: Although the value stored to >> 'field' is used in the enclosing expression, the value is never actually >> read from 'field' [clang-analyzer-deadcode.DeadStores] hid_input_fetch_field(hid, field = report->field[a], data); ^ ~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1665:30: note: Although the value stored to 'field' is used in the enclosing expression, the value is never actually read from 'field' hid_input_fetch_field(hid, field = report->field[a], data); ^ ~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:2198:3: warning: Value stored to 'len' is never read [clang-analyzer-deadcode.DeadStores] len += sprintf(buf + len, "%shidraw%d", len ? "," : "", ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:2198:3: note: Value stored to 'len' is never read len += sprintf(buf + len, "%shidraw%d", len ? "," : "", ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 6 warnings generated. include/linux/hid.h:1049:9: warning: Access to field 'name' results in a dereference of a null pointer (loaded from variable 'input') [clang-analyzer-core.NullDereference] input->name, c, type); ^ drivers/hid/hid-corsair.c:635:6: note: Assuming the condition is false if ((usage->hid & HID_USAGE_PAGE) != HID_UP_KEYBOARD) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-corsair.c:635:2: note: Taking false branch if ((usage->hid & HID_USAGE_PAGE) != HID_UP_KEYBOARD) ^ drivers/hid/hid-corsair.c:639:6: note: 'gkey' is not equal to 0 if (gkey != 0) { ^~~~ drivers/hid/hid-corsair.c:639:2: note: Taking true branch if (gkey != 0) { ^ drivers/hid/hid-corsair.c:640:3: note: Calling 'hid_map_usage_clear' hid_map_usage_clear(input, usage, bit, max, EV_KEY, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/hid.h:1077:2: note: Calling 'hid_map_usage' hid_map_usage(hidinput, usage, bit, max, type, c); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/hid.h:1020:2: note: 'input' initialized here struct input_dev *input = hidinput->input; ^~~~~~~~~~~~~~~~~~~~~~~ include/linux/hid.h:1024:2: note: Control jumps to 'case 1:' at line 1033 switch (type) { ^ include/linux/hid.h:1036:3: note: Execution continues on line 1047 break; ^ include/linux/hid.h:1047:15: note: Assuming 'c' is <= 'limit' if (unlikely(c > limit || !bmap)) { ^ include/linux/compiler.h:78:42: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ include/linux/hid.h:1047:15: note: Left side of '||' is false if (unlikely(c > limit || !bmap)) { ^ include/linux/hid.h:1047:28: note: Assuming 'bmap' is null if (unlikely(c > limit || !bmap)) { ^ include/linux/compiler.h:78:42: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ include/linux/hid.h:1047:28: note: Assuming pointer value is null if (unlikely(c > limit || !bmap)) { ^ include/linux/compiler.h:78:42: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ include/linux/hid.h:1047:2: note: Taking true branch if (unlikely(c > limit || !bmap)) { ^ include/linux/hid.h:1048:3: note: Assuming the condition is true pr_warn_ratelimited("%s: Invalid code %d type %d\n", ^ include/linux/printk.h:660:2: note: expanded from macro 'pr_warn_ratelimited' printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/printk.h:643:6: note: expanded from macro 'printk_ratelimited' if (__ratelimit(&_rs)) \ ^~~~~~~~~~~~~~~~~ include/linux/ratelimit_types.h:41:28: note: expanded from macro '__ratelimit' #define __ratelimit(state) ___ratelimit(state, __func__) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/hid.h:1048:3: note: Taking true branch pr_warn_ratelimited("%s: Invalid code %d type %d\n", ^ include/linux/printk.h:660:2: note: expanded from macro 'pr_warn_ratelimited' printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^ include/linux/printk.h:643:2: note: expanded from macro 'printk_ratelimited' if (__ratelimit(&_rs)) \ ^ include/linux/hid.h:1048:3: note: Loop condition is false. Exiting loop pr_warn_ratelimited("%s: Invalid code %d type %d\n", ^ include/linux/printk.h:660:2: note: expanded from macro 'pr_warn_ratelimited' printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^ include/linux/printk.h:644:3: note: expanded from macro 'printk_ratelimited' printk(fmt, ##__VA_ARGS__); \ vim +1665 drivers/hid/hid-core.c dde5845a529ff7 Jiri Kosina 2006-12-08 1648 d95c6e8572e0df Benjamin Tissoires 2022-01-26 1649 /* d95c6e8572e0df Benjamin Tissoires 2022-01-26 1650 * Analyse a received report, and fetch the data from it. The field d95c6e8572e0df Benjamin Tissoires 2022-01-26 1651 * content is stored for next report processing (we do differential d95c6e8572e0df Benjamin Tissoires 2022-01-26 1652 * reporting to the layer). d95c6e8572e0df Benjamin Tissoires 2022-01-26 1653 */ d95c6e8572e0df Benjamin Tissoires 2022-01-26 1654 static void hid_process_report(struct hid_device *hid, d95c6e8572e0df Benjamin Tissoires 2022-01-26 1655 struct hid_report *report, d95c6e8572e0df Benjamin Tissoires 2022-01-26 1656 __u8 *data, d95c6e8572e0df Benjamin Tissoires 2022-01-26 1657 int interrupt) d95c6e8572e0df Benjamin Tissoires 2022-01-26 1658 { d95c6e8572e0df Benjamin Tissoires 2022-01-26 1659 unsigned int a; 5f297c23cba491 Benjamin Tissoires 2022-01-26 1660 struct hid_field_entry *entry; d95c6e8572e0df Benjamin Tissoires 2022-01-26 1661 struct hid_field *field; d95c6e8572e0df Benjamin Tissoires 2022-01-26 1662 5f297c23cba491 Benjamin Tissoires 2022-01-26 1663 /* first retrieve all incoming values in data */ 5f297c23cba491 Benjamin Tissoires 2022-01-26 1664 for (a = 0; a < report->maxfield; a++) 5f297c23cba491 Benjamin Tissoires 2022-01-26 @1665 hid_input_fetch_field(hid, field = report->field[a], data); 5f297c23cba491 Benjamin Tissoires 2022-01-26 1666 5f297c23cba491 Benjamin Tissoires 2022-01-26 1667 if (!list_empty(&report->field_entry_list)) { 5f297c23cba491 Benjamin Tissoires 2022-01-26 1668 /* INPUT_REPORT, we have a priority list of fields */ 5f297c23cba491 Benjamin Tissoires 2022-01-26 1669 list_for_each_entry(entry, 5f297c23cba491 Benjamin Tissoires 2022-01-26 1670 &report->field_entry_list, 5f297c23cba491 Benjamin Tissoires 2022-01-26 1671 list) { 5f297c23cba491 Benjamin Tissoires 2022-01-26 1672 field = entry->field; 5f297c23cba491 Benjamin Tissoires 2022-01-26 1673 5f297c23cba491 Benjamin Tissoires 2022-01-26 1674 if (field->flags & HID_MAIN_ITEM_VARIABLE) 5f297c23cba491 Benjamin Tissoires 2022-01-26 1675 hid_process_event(hid, 5f297c23cba491 Benjamin Tissoires 2022-01-26 1676 field, 5f297c23cba491 Benjamin Tissoires 2022-01-26 1677 &field->usage[entry->index], 5f297c23cba491 Benjamin Tissoires 2022-01-26 1678 field->new_value[entry->index], 5f297c23cba491 Benjamin Tissoires 2022-01-26 1679 interrupt); 5f297c23cba491 Benjamin Tissoires 2022-01-26 1680 else 5f297c23cba491 Benjamin Tissoires 2022-01-26 1681 hid_input_array_field(hid, field, interrupt); 5f297c23cba491 Benjamin Tissoires 2022-01-26 1682 } 5f297c23cba491 Benjamin Tissoires 2022-01-26 1683 5f297c23cba491 Benjamin Tissoires 2022-01-26 1684 /* we need to do the memcpy at the end for var items */ d95c6e8572e0df Benjamin Tissoires 2022-01-26 1685 for (a = 0; a < report->maxfield; a++) { d95c6e8572e0df Benjamin Tissoires 2022-01-26 1686 field = report->field[a]; d95c6e8572e0df Benjamin Tissoires 2022-01-26 1687 5f297c23cba491 Benjamin Tissoires 2022-01-26 1688 if (field->flags & HID_MAIN_ITEM_VARIABLE) 5f297c23cba491 Benjamin Tissoires 2022-01-26 1689 memcpy(field->value, field->new_value, 5f297c23cba491 Benjamin Tissoires 2022-01-26 1690 field->report_count * sizeof(__s32)); 5f297c23cba491 Benjamin Tissoires 2022-01-26 1691 } 5f297c23cba491 Benjamin Tissoires 2022-01-26 1692 } else { 5f297c23cba491 Benjamin Tissoires 2022-01-26 1693 /* FEATURE_REPORT, regular processing */ 5f297c23cba491 Benjamin Tissoires 2022-01-26 1694 for (a = 0; a < report->maxfield; a++) { 5f297c23cba491 Benjamin Tissoires 2022-01-26 1695 field = report->field[a]; d95c6e8572e0df Benjamin Tissoires 2022-01-26 1696 d95c6e8572e0df Benjamin Tissoires 2022-01-26 1697 if (field->flags & HID_MAIN_ITEM_VARIABLE) d95c6e8572e0df Benjamin Tissoires 2022-01-26 1698 hid_input_var_field(hid, field, interrupt); d95c6e8572e0df Benjamin Tissoires 2022-01-26 1699 else d95c6e8572e0df Benjamin Tissoires 2022-01-26 1700 hid_input_array_field(hid, field, interrupt); d95c6e8572e0df Benjamin Tissoires 2022-01-26 1701 } d95c6e8572e0df Benjamin Tissoires 2022-01-26 1702 } 5f297c23cba491 Benjamin Tissoires 2022-01-26 1703 } d95c6e8572e0df Benjamin Tissoires 2022-01-26 1704 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected] _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
