drivers/char/ipmi/ipmi_msghandler.c:768 ipmi_smi_watcher_register() warn: iterator used outside loop: 'intf'
kernel test robot
build botBCC: [email protected]
CC: [email protected]
TO: Corey Minyard <[email protected]>
tree: https://github.com/cminyard/linux-ipmi remove-srcu head: 952a7280d75bee86fb667526304477074b678a68 commit: ed7043aba7c5cb3017e4d2d7dd6e9c5f2dbb1df7 [8/15] ipmi:msghandler: Remove srcu for the ipmi_interfaces list
:::::: branch date: 2 days ago
:::::: commit date: 4 days ago
config: openrisc-randconfig-r073-20250321 (https://download.01.org/0day-ci/archive/20250324/[email protected]/config)
compiler: or1k-linux-gcc (GCC) 11.5.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:drivers/char/ipmi/ipmi_msghandler.c:768 ipmi_smi_watcher_register() warn: iterator used outside loop: 'intf'
vim +/intf +768 drivers/char/ipmi/ipmi_msghandler.c
393d2cc354d150 Corey Minyard 2005-11-07 720
^1da177e4c3f41 Linus Torvalds 2005-04-16 721 int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
^1da177e4c3f41 Linus Torvalds 2005-04-16 722 {
a567b6230066e3 Corey Minyard 2018-04-05 723 struct ipmi_smi *intf;
ed7043aba7c5cb Corey Minyard 2025-03-18 724 unsigned int count = 0, i;
ed7043aba7c5cb Corey Minyard 2025-03-18 725 int *interfaces = NULL;
ed7043aba7c5cb Corey Minyard 2025-03-18 726 int rv = 0;
913a89f009d98c Corey Minyard 2018-12-20 727
913a89f009d98c Corey Minyard 2018-12-20 728 /*
913a89f009d98c Corey Minyard 2018-12-20 729 * Make sure the driver is actually initialized, this handles
913a89f009d98c Corey Minyard 2018-12-20 730 * problems with initialization order.
913a89f009d98c Corey Minyard 2018-12-20 731 */
913a89f009d98c Corey Minyard 2018-12-20 732 rv = ipmi_init_msghandler();
913a89f009d98c Corey Minyard 2018-12-20 733 if (rv)
913a89f009d98c Corey Minyard 2018-12-20 734 return rv;
bca0324d09e413 Corey Minyard 2006-12-06 735
b2c03941b50944 Corey Minyard 2006-12-06 736 mutex_lock(&smi_watchers_mutex);
b2c03941b50944 Corey Minyard 2006-12-06 737
b2c03941b50944 Corey Minyard 2006-12-06 738 list_add(&watcher->link, &smi_watchers);
bca0324d09e413 Corey Minyard 2006-12-06 739
ed7043aba7c5cb Corey Minyard 2025-03-18 740 /*
ed7043aba7c5cb Corey Minyard 2025-03-18 741 * Build an array of ipmi interfaces and fill it in. We can't
ed7043aba7c5cb Corey Minyard 2025-03-18 742 * call the callback with ipmi_interfaces_mutex held.
ed7043aba7c5cb Corey Minyard 2025-03-18 743 * smi_watchers_mutex will keep things in order for the user.
ed7043aba7c5cb Corey Minyard 2025-03-18 744 */
ed7043aba7c5cb Corey Minyard 2025-03-18 745 mutex_lock(&ipmi_interfaces_mutex);
ed7043aba7c5cb Corey Minyard 2025-03-18 746 list_for_each_entry(intf, &ipmi_interfaces, link)
ed7043aba7c5cb Corey Minyard 2025-03-18 747 count++;
ed7043aba7c5cb Corey Minyard 2025-03-18 748 if (count > 0) {
ed7043aba7c5cb Corey Minyard 2025-03-18 749 interfaces = kmalloc_array(count, sizeof(*interfaces),
ed7043aba7c5cb Corey Minyard 2025-03-18 750 GFP_KERNEL);
ed7043aba7c5cb Corey Minyard 2025-03-18 751 if (!interfaces)
ed7043aba7c5cb Corey Minyard 2025-03-18 752 rv = -ENOMEM;
ed7043aba7c5cb Corey Minyard 2025-03-18 753 count = 0;
ed7043aba7c5cb Corey Minyard 2025-03-18 754 }
ed7043aba7c5cb Corey Minyard 2025-03-18 755 if (interfaces) {
ed7043aba7c5cb Corey Minyard 2025-03-18 756 list_for_each_entry(intf, &ipmi_interfaces, link) {
e86ee2d44b4405 Corey Minyard 2018-04-05 757 int intf_num = READ_ONCE(intf->intf_num);
bca0324d09e413 Corey Minyard 2006-12-06 758
e86ee2d44b4405 Corey Minyard 2018-04-05 759 if (intf_num == -1)
e86ee2d44b4405 Corey Minyard 2018-04-05 760 continue;
ed7043aba7c5cb Corey Minyard 2025-03-18 761 interfaces[count++] = intf_num;
ed7043aba7c5cb Corey Minyard 2025-03-18 762 }
ed7043aba7c5cb Corey Minyard 2025-03-18 763 }
ed7043aba7c5cb Corey Minyard 2025-03-18 764 mutex_unlock(&ipmi_interfaces_mutex);
ed7043aba7c5cb Corey Minyard 2025-03-18 765
ed7043aba7c5cb Corey Minyard 2025-03-18 766 if (interfaces) {
ed7043aba7c5cb Corey Minyard 2025-03-18 767 for (i = 0; i < count; i++)
ed7043aba7c5cb Corey Minyard 2025-03-18 @768 watcher->new_smi(interfaces[i], intf->si_dev);
ed7043aba7c5cb Corey Minyard 2025-03-18 769 kfree(interfaces);
^1da177e4c3f41 Linus Torvalds 2005-04-16 770 }
bca0324d09e413 Corey Minyard 2006-12-06 771
b2c03941b50944 Corey Minyard 2006-12-06 772 mutex_unlock(&smi_watchers_mutex);
bca0324d09e413 Corey Minyard 2006-12-06 773
ed7043aba7c5cb Corey Minyard 2025-03-18 774 return rv;
^1da177e4c3f41 Linus Torvalds 2005-04-16 775 }
c70d749986f6f1 Corey Minyard 2008-04-29 776 EXPORT_SYMBOL(ipmi_smi_watcher_register);
^1da177e4c3f41 Linus Torvalds 2005-04-16 777 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki