CC: [email protected] CC: [email protected] BCC: [email protected] In-Reply-To: <[email protected]> References: <[email protected]> TO: Chen Guanqiao <[email protected]> TO: [email protected] TO: [email protected] TO: [email protected] CC: Chen Guanqiao <[email protected]>
Hi Chen, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on cminyard-ipmi/for-next] [also build test WARNING on v5.17 next-20220325] [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/intel-lab-lkp/linux/commits/Chen-Guanqiao/ipmi-msghandler-Get-the-number-of-user-through-sysfs/20220328-005308 base: https://github.com/cminyard/linux-ipmi for-next :::::: branch date: 8 hours ago :::::: commit date: 8 hours ago config: arm-randconfig-c002-20220327 (https://download.01.org/0day-ci/archive/20220328/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 0f6d9501cf49ce02937099350d08f20c4af86f3d) 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 arm cross compiling tool for clang build # apt-get install binutils-arm-linux-gnueabi # https://github.com/intel-lab-lkp/linux/commit/56b9ec5a2846208cd82155435eae0c15622057e5 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Chen-Guanqiao/ipmi-msghandler-Get-the-number-of-user-through-sysfs/20220328-005308 git checkout 56b9ec5a2846208cd82155435eae0c15622057e5 # save the config file to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm 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 >>) include/linux/kref.h:65:3: note: Calling 'intf_free' release(kref); ^~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:721:2: note: Attempt to free released memory kfree(intf); ^~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2352:3: warning: Potential leak of memory pointed to by 'smi_msg' [clang-analyzer-unix.Malloc] ipmi_free_recv_msg(recv_msg); ^ drivers/char/ipmi/ipmi_msghandler.c:3638:6: note: Assuming field 'in_shutdown' is false if (!intf->in_shutdown) ^~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:3638:2: note: Taking true branch if (!intf->in_shutdown) ^ drivers/char/ipmi/ipmi_msghandler.c:3639:3: note: Calling 'bmc_get_device_id' bmc_get_device_id(intf, NULL, NULL, NULL, NULL); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2709:9: note: Calling '__bmc_get_device_id' return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2578:18: note: 'intf' is not equal to NULL bool intf_set = intf != NULL; ^~~~ drivers/char/ipmi/ipmi_msghandler.c:2580:7: note: 'intf' is non-null if (!intf) { ^~~~ drivers/char/ipmi/ipmi_msghandler.c:2580:2: note: Taking false branch if (!intf) { ^ drivers/char/ipmi/ipmi_msghandler.c:2607:6: note: Assuming field 'in_bmc_register' is false if (intf->in_bmc_register || ^~~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2607:6: note: Left side of '||' is false drivers/char/ipmi/ipmi_msghandler.c:2608:7: note: Assuming field 'dyn_id_set' is 0 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) ^~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2608:23: note: Left side of '&&' is false (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) ^ drivers/char/ipmi/ipmi_msghandler.c:2612:2: note: Calling '__get_guid' __get_guid(intf); ^~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:3459:7: note: Calling 'send_guid_cmd' rv = send_guid_cmd(intf, 0); ^~~~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:3403:9: note: Calling 'i_ipmi_request' return i_ipmi_request(NULL, ^~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2290:6: note: 'supplied_recv' is null if (supplied_recv) ^~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2290:2: note: Taking false branch if (supplied_recv) ^ drivers/char/ipmi/ipmi_msghandler.c:2294:7: note: 'recv_msg' is not equal to NULL if (recv_msg == NULL) { ^~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2294:3: note: Taking false branch if (recv_msg == NULL) { ^ drivers/char/ipmi/ipmi_msghandler.c:2301:6: note: 'supplied_smi' is null if (supplied_smi) ^~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2301:2: note: Taking false branch if (supplied_smi) ^ drivers/char/ipmi/ipmi_msghandler.c:2304:13: note: Calling 'ipmi_alloc_smi_msg' smi_msg = ipmi_alloc_smi_msg(); ^~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:5204:7: note: Memory is allocated rv = kmalloc(sizeof(struct ipmi_smi_msg), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:5205:6: note: Assuming 'rv' is non-null if (rv) { ^~ drivers/char/ipmi/ipmi_msghandler.c:5205:2: note: Taking true branch if (rv) { ^ drivers/char/ipmi/ipmi_msghandler.c:2304:13: note: Returned allocated memory smi_msg = ipmi_alloc_smi_msg(); ^~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2305:7: note: 'smi_msg' is not equal to NULL if (smi_msg == NULL) { ^~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2305:3: note: Taking false branch if (smi_msg == NULL) { ^ drivers/char/ipmi/ipmi_msghandler.c:2314:6: note: Assuming field 'in_shutdown' is true if (intf->in_shutdown) { ^~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2314:2: note: Taking true branch if (intf->in_shutdown) { ^ drivers/char/ipmi/ipmi_msghandler.c:2316:3: note: Control jumps to line 2351 goto out_err; ^ drivers/char/ipmi/ipmi_msghandler.c:2352:3: note: Potential leak of memory pointed to by 'smi_msg' ipmi_free_recv_msg(recv_msg); ^ >> drivers/char/ipmi/ipmi_msghandler.c:2816:2: warning: Use of memory after it >> is freed [clang-analyzer-unix.Malloc] list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { ^ include/linux/rculist.h:393:9: note: expanded from macro 'list_for_each_entry_rcu' pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) ^ include/linux/rculist.h:307:15: note: expanded from macro 'list_entry_rcu' container_of(READ_ONCE(ptr), type, member) ^ include/asm-generic/rwonce.h:50:2: note: expanded from macro 'READ_ONCE' __READ_ONCE(x); \ ^ include/asm-generic/rwonce.h:44:24: note: expanded from macro '__READ_ONCE' #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) ^ drivers/char/ipmi/ipmi_msghandler.c:3025:6: note: Assuming the condition is false if (!sysfs_streq(buf, "1")) ^~~~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:3025:2: note: Taking false branch if (!sysfs_streq(buf, "1")) ^ drivers/char/ipmi/ipmi_msghandler.c:3028:2: note: Calling 'cleanup_msgs_queue' cleanup_msgs_queue(); ^~~~~~~~~~~~~~~~~~~~ drivers/char/ipmi/ipmi_msghandler.c:2816:2: note: Left side of '||' is false list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { ^ include/linux/rculist.h:391:13: note: expanded from macro 'list_for_each_entry_rcu' pos = list_entry_rcu((head)->next, typeof(*pos), member); \ ^ include/linux/rculist.h:307:15: note: expanded from macro 'list_entry_rcu' container_of(READ_ONCE(ptr), type, member) ^ include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE' compiletime_assert_rwonce_type(x); \ ^ include/asm-generic/rwonce.h:36:21: note: expanded from macro 'compiletime_assert_rwonce_type' compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ ^ include/linux/compiler_types.h:313:3: note: expanded from macro '__native_word' (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \ ^ drivers/char/ipmi/ipmi_msghandler.c:2816:2: note: Left side of '||' is false list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { ^ include/linux/rculist.h:391:13: note: expanded from macro 'list_for_each_entry_rcu' pos = list_entry_rcu((head)->next, typeof(*pos), member); \ ^ include/linux/rculist.h:307:15: note: expanded from macro 'list_entry_rcu' container_of(READ_ONCE(ptr), type, member) ^ include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE' compiletime_assert_rwonce_type(x); \ ^ include/asm-generic/rwonce.h:36:21: note: expanded from macro 'compiletime_assert_rwonce_type' compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ ^ include/linux/compiler_types.h:313:3: note: expanded from macro '__native_word' (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \ ^ drivers/char/ipmi/ipmi_msghandler.c:2816:2: note: Left side of '||' is true list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { ^ include/linux/rculist.h:391:13: note: expanded from macro 'list_for_each_entry_rcu' pos = list_entry_rcu((head)->next, typeof(*pos), member); \ ^ include/linux/rculist.h:307:15: note: expanded from macro 'list_entry_rcu' container_of(READ_ONCE(ptr), type, member) ^ include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE' compiletime_assert_rwonce_type(x); \ ^ include/asm-generic/rwonce.h:36:21: note: expanded from macro 'compiletime_assert_rwonce_type' compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ ^ include/linux/compiler_types.h:314:28: note: expanded from macro '__native_word' sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) ^ drivers/char/ipmi/ipmi_msghandler.c:2816:2: note: Taking false branch list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { ^ include/linux/rculist.h:391:13: note: expanded from macro 'list_for_each_entry_rcu' pos = list_entry_rcu((head)->next, typeof(*pos), member); \ ^ include/linux/rculist.h:307:15: note: expanded from macro 'list_entry_rcu' container_of(READ_ONCE(ptr), type, member) ^ include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE' compiletime_assert_rwonce_type(x); \ ^ note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:346:2: note: expanded from macro 'compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^ include/linux/compiler_types.h:334:2: note: expanded from macro '_compiletime_assert' __compiletime_assert(condition, msg, prefix, suffix) ^ include/linux/compiler_types.h:326:3: note: expanded from macro '__compiletime_assert' if (!(condition)) \ ^ drivers/char/ipmi/ipmi_msghandler.c:2816:2: note: Loop condition is false. Exiting loop vim +2816 drivers/char/ipmi/ipmi_msghandler.c 56b9ec5a284620 Chen Guanqiao 2022-03-28 2809 56b9ec5a284620 Chen Guanqiao 2022-03-28 2810 static void cleanup_msgs_queue(void) 56b9ec5a284620 Chen Guanqiao 2022-03-28 2811 { 56b9ec5a284620 Chen Guanqiao 2022-03-28 2812 struct ipmi_smi *intf; 56b9ec5a284620 Chen Guanqiao 2022-03-28 2813 int index; 56b9ec5a284620 Chen Guanqiao 2022-03-28 2814 56b9ec5a284620 Chen Guanqiao 2022-03-28 2815 index = srcu_read_lock(&ipmi_interfaces_srcu); 56b9ec5a284620 Chen Guanqiao 2022-03-28 @2816 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { 56b9ec5a284620 Chen Guanqiao 2022-03-28 2817 struct bmc_device *bmc = intf->bmc; 56b9ec5a284620 Chen Guanqiao 2022-03-28 2818 56b9ec5a284620 Chen Guanqiao 2022-03-28 2819 kref_get(&intf->refcount); 56b9ec5a284620 Chen Guanqiao 2022-03-28 2820 mutex_lock(&intf->bmc_reg_mutex); 56b9ec5a284620 Chen Guanqiao 2022-03-28 2821 mutex_lock(&bmc->dyn_mutex); 56b9ec5a284620 Chen Guanqiao 2022-03-28 2822 56b9ec5a284620 Chen Guanqiao 2022-03-28 2823 __cleanup_msgs_queue(intf); 56b9ec5a284620 Chen Guanqiao 2022-03-28 2824 56b9ec5a284620 Chen Guanqiao 2022-03-28 2825 mutex_unlock(&bmc->dyn_mutex); 56b9ec5a284620 Chen Guanqiao 2022-03-28 2826 mutex_unlock(&intf->bmc_reg_mutex); 56b9ec5a284620 Chen Guanqiao 2022-03-28 2827 kref_put(&intf->refcount, intf_free); 56b9ec5a284620 Chen Guanqiao 2022-03-28 2828 } 56b9ec5a284620 Chen Guanqiao 2022-03-28 2829 srcu_read_unlock(&ipmi_interfaces_srcu, index); 56b9ec5a284620 Chen Guanqiao 2022-03-28 2830 } 56b9ec5a284620 Chen Guanqiao 2022-03-28 2831 -- 0-DAY CI Kernel Test Service https://01.org/lkp _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
