From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3069667398490596661==" MIME-Version: 1.0 From: kernel test robot Subject: Re: [PATCH 08/12] HID: core: for input reports, process the usages by priority list Date: Sun, 30 Jan 2022 05:57:07 +0800 Message-ID: <202201300505.1LcHvClV-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============3069667398490596661== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: llvm(a)lists.linux.dev CC: kbuild-all(a)lists.01.org In-Reply-To: <20220126161832.3193805-9-benjamin.tissoires@redhat.com> References: <20220126161832.3193805-9-benjamin.tissoires@redhat.com> TO: Benjamin Tissoires TO: Jiri Kosina TO: Dmitry Torokhov TO: Jonathan Corbet TO: "Ahelenia Ziemia=C5=84ska" TO: Ping Cheng TO: Aaron Armstrong Skomra TO: Jason Gerecke TO: Peter Hutterer CC: linux-input(a)vger.kernel.org CC: linux-doc(a)vger.kernel.org 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/arc= hive/20220130/202201300505.1LcHvClV-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 2a1b7a= a016c0f4b5598806205bdfbab1ea2d92c4) reproduce (this is a W=3D1 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/5f297c23cba491924689834a0= 1ef511263c9e547 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Benjamin-Tissoires/HID-fix-for-gen= eric-input-processing/20220127-002107 git checkout 5f297c23cba491924689834a01ef511263c9e547 # save the config file to linux build tree COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang make.cross ARCH= =3Driscv clang-analyzer = If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot 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 =3D=3D HID_REQ_SET_REPORT) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1936:2: note: Taking true branch if (reqtype =3D=3D 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 <=3D 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 =3D 0; n < report->maxfield; n++) ^~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1848:2: note: Loop condition is true. Entering l= oop body for (n =3D 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 =3D field->report_size; ^~~~~~~~~~~~~ drivers/hid/hid-core.c:1814:14: note: Assuming 'n' is < 'count' for (n =3D 0; n < count; n++) { ^~~~~~~~~ drivers/hid/hid-core.c:1814:2: note: Loop condition is true. Entering l= oop body for (n =3D 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 <=3D 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 >=3D 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 =3D 0; n < count; n++) { ^~~~~~~~~ drivers/hid/hid-core.c:1814:2: note: Loop condition is true. Entering l= oop body for (n =3D 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 param= eter '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 !=3D -1) ^ drivers/hid/hid-core.c:1339:8: note: Left side of '&&' is false if (a && a !=3D -1) ^ drivers/hid/hid-core.c:1341:21: note: The result of the left shift is un= defined 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 'f= ield' is used in the enclosing expression, the value is never actually read= from 'field' [clang-analyzer-deadcode.DeadStores] hid_input_fetch_field(hid, field =3D report->field[a], d= ata); ^ ~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:1665:30: note: Although the value stored to 'fiel= d' is used in the enclosing expression, the value is never actually read fr= om 'field' hid_input_fetch_field(hid, field =3D report->field[a], d= ata); ^ ~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:2198:3: warning: Value stored to 'len' is never r= ead [clang-analyzer-deadcode.DeadStores] len +=3D sprintf(buf + len, "%shidraw%d", len ? "," : "", ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-core.c:2198:3: note: Value stored to 'len' is never read len +=3D sprintf(buf + len, "%shidraw%d", len ? "," : "", ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 5 warnings (5 in non-user code). Use -header-filter=3D.* to display errors from all non-system headers. U= se -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=3D.* to display errors from all non-system headers. U= se -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-analyz= er-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) !=3D HID_UP_KEYBOARD) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/hid/hid-corsair.c:635:2: note: Taking false branch if ((usage->hid & HID_USAGE_PAGE) !=3D HID_UP_KEYBOARD) ^ drivers/hid/hid-corsair.c:639:6: note: 'gkey' is not equal to 0 if (gkey !=3D 0) { ^~~~ drivers/hid/hid-corsair.c:639:2: note: Taking true branch if (gkey !=3D 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 =3D hidinput->input; ^~~~~~~~~~~~~~~~~~~~~~~ include/linux/hid.h:1024:2: note: Control jumps to 'case 1:' at line 10= 33 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 <=3D '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_ratelim= ited' printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/printk.h:643:6: note: expanded from macro 'printk_ratelimi= ted' if (__ratelimit(&_rs)) \ ^~~~~~~~~~~~~~~~~ include/linux/ratelimit_types.h:41:28: note: expanded from macro '__rate= limit' #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_ratelim= ited' printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^ include/linux/printk.h:643:2: note: expanded from macro 'printk_ratelimi= ted' 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_ratelim= ited' printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^ include/linux/printk.h:644:3: note: expanded from macro 'printk_ratelimi= ted' 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 r= eport, and fetch the data from it. The field d95c6e8572e0df Benjamin Tissoires 2022-01-26 1651 * content is stored fo= r next report processing (we do differential d95c6e8572e0df Benjamin Tissoires 2022-01-26 1652 * reporting to the lay= er). 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_re= port *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 *fiel= d; 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 =3D 0; a < repo= rt->maxfield; a++) 5f297c23cba491 Benjamin Tissoires 2022-01-26 @1665 hid_input_fetch_field= (hid, field =3D report->field[a], data); 5f297c23cba491 Benjamin Tissoires 2022-01-26 1666 = 5f297c23cba491 Benjamin Tissoires 2022-01-26 1667 if (!list_empty(&repor= t->field_entry_list)) { 5f297c23cba491 Benjamin Tissoires 2022-01-26 1668 /* INPUT_REPORT, we h= ave a priority list of fields */ 5f297c23cba491 Benjamin Tissoires 2022-01-26 1669 list_for_each_entry(e= ntry, 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 =3D entry->fie= ld; 5f297c23cba491 Benjamin Tissoires 2022-01-26 1673 = 5f297c23cba491 Benjamin Tissoires 2022-01-26 1674 if (field->flags & H= ID_MAIN_ITEM_VARIABLE) 5f297c23cba491 Benjamin Tissoires 2022-01-26 1675 hid_process_event(h= id, 5f297c23cba491 Benjamin Tissoires 2022-01-26 1676 field, 5f297c23cba491 Benjamin Tissoires 2022-01-26 1677 &field->usage[e= ntry->index], 5f297c23cba491 Benjamin Tissoires 2022-01-26 1678 field->new_valu= e[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_fie= ld(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 =3D 0; a < rep= ort->maxfield; a++) { d95c6e8572e0df Benjamin Tissoires 2022-01-26 1686 field =3D report->fi= eld[a]; d95c6e8572e0df Benjamin Tissoires 2022-01-26 1687 = 5f297c23cba491 Benjamin Tissoires 2022-01-26 1688 if (field->flags & H= ID_MAIN_ITEM_VARIABLE) 5f297c23cba491 Benjamin Tissoires 2022-01-26 1689 memcpy(field->value= , field->new_value, 5f297c23cba491 Benjamin Tissoires 2022-01-26 1690 field->repor= t_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, re= gular processing */ 5f297c23cba491 Benjamin Tissoires 2022-01-26 1694 for (a =3D 0; a < rep= ort->maxfield; a++) { 5f297c23cba491 Benjamin Tissoires 2022-01-26 1695 field =3D report->fi= eld[a]; d95c6e8572e0df Benjamin Tissoires 2022-01-26 1696 = d95c6e8572e0df Benjamin Tissoires 2022-01-26 1697 if (field->flags & H= ID_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_fie= ld(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/kbuild-all(a)lists.01.org --===============3069667398490596661==--