From: Dan Carpenter <dan.carpenter@linaro.org>
To: oe-kbuild@lists.linux.dev,
Weitao Wang <WeitaoWang-oc@zhaoxin.com>,
gregkh@linuxfoundation.org, mathias.nyman@intel.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
WeitaoWang@zhaoxin.com, wwt8723@163.com, CobeChen@zhaoxin.com,
stable@vger.kernel.org
Subject: Re: [PATCH v3] usb:xhci:Fix slot_id resource race conflict
Date: Fri, 1 Aug 2025 17:31:41 +0300 [thread overview]
Message-ID: <b5ab0f46-0fde-420e-97a2-136d3074b59c@suswa.mountain> (raw)
In-Reply-To: <20250730152715.8368-1-WeitaoWang-oc@zhaoxin.com>
Hi Weitao,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Weitao-Wang/usb-xhci-Fix-slot_id-resource-race-conflict/20250730-183802
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link: https://lore.kernel.org/r/20250730152715.8368-1-WeitaoWang-oc%40zhaoxin.com
patch subject: [PATCH v3] usb:xhci:Fix slot_id resource race conflict
config: x86_64-randconfig-161-20250801 (https://download.01.org/0day-ci/archive/20250801/202508010850.Bqd6wf47-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.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 <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202508010850.Bqd6wf47-lkp@intel.com/
New smatch warnings:
drivers/usb/host/xhci-mem.c:913 xhci_free_virt_device() warn: variable dereferenced before check 'dev->out_ctx' (see line 878)
vim +913 drivers/usb/host/xhci-mem.c
0b5ed80150eb59 Weitao Wang 2025-07-30 868 void xhci_free_virt_device(struct xhci_hcd *xhci, struct xhci_virt_device *dev,
0b5ed80150eb59 Weitao Wang 2025-07-30 869 int slot_id)
3ffbba9511b414 Sarah Sharp 2009-04-27 870 {
3ffbba9511b414 Sarah Sharp 2009-04-27 871 int i;
2e27980e6eb781 Sarah Sharp 2011-09-02 872 int old_active_eps = 0;
3ffbba9511b414 Sarah Sharp 2009-04-27 873
3ffbba9511b414 Sarah Sharp 2009-04-27 874 /* Slot ID 0 is reserved */
0b5ed80150eb59 Weitao Wang 2025-07-30 875 if (slot_id == 0 || !dev)
3ffbba9511b414 Sarah Sharp 2009-04-27 876 return;
3ffbba9511b414 Sarah Sharp 2009-04-27 877
0b5ed80150eb59 Weitao Wang 2025-07-30 @878 if (xhci->dcbaa->dev_context_ptrs[slot_id] == cpu_to_le64(dev->out_ctx->dma))
^^^^^^^^^^^^
dev->out_ctx dereferenced without checking for NULL
8e595a5d30a5ee Sarah Sharp 2009-07-27 879 xhci->dcbaa->dev_context_ptrs[slot_id] = 0;
3ffbba9511b414 Sarah Sharp 2009-04-27 880
d850c1658328e7 Zhengjun Xing 2018-06-21 881 trace_xhci_free_virt_device(dev);
d850c1658328e7 Zhengjun Xing 2018-06-21 882
2e27980e6eb781 Sarah Sharp 2011-09-02 883 if (dev->tt_info)
2e27980e6eb781 Sarah Sharp 2011-09-02 884 old_active_eps = dev->tt_info->active_eps;
2e27980e6eb781 Sarah Sharp 2011-09-02 885
98871e9470a50c Felipe Balbi 2017-01-23 886 for (i = 0; i < 31; i++) {
63a0d9abd18cdc Sarah Sharp 2009-09-04 887 if (dev->eps[i].ring)
63a0d9abd18cdc Sarah Sharp 2009-09-04 888 xhci_ring_free(xhci, dev->eps[i].ring);
8df75f42f8e67e Sarah Sharp 2010-04-02 889 if (dev->eps[i].stream_info)
8df75f42f8e67e Sarah Sharp 2010-04-02 890 xhci_free_stream_info(xhci,
8df75f42f8e67e Sarah Sharp 2010-04-02 891 dev->eps[i].stream_info);
5aed5b7c2430ce Mathias Nyman 2022-10-24 892 /*
5aed5b7c2430ce Mathias Nyman 2022-10-24 893 * Endpoints are normally deleted from the bandwidth list when
5aed5b7c2430ce Mathias Nyman 2022-10-24 894 * endpoints are dropped, before device is freed.
5aed5b7c2430ce Mathias Nyman 2022-10-24 895 * If host is dying or being removed then endpoints aren't
5aed5b7c2430ce Mathias Nyman 2022-10-24 896 * dropped cleanly, so delete the endpoint from list here.
5aed5b7c2430ce Mathias Nyman 2022-10-24 897 * Only applicable for hosts with software bandwidth checking.
2e27980e6eb781 Sarah Sharp 2011-09-02 898 */
5aed5b7c2430ce Mathias Nyman 2022-10-24 899
5aed5b7c2430ce Mathias Nyman 2022-10-24 900 if (!list_empty(&dev->eps[i].bw_endpoint_list)) {
5aed5b7c2430ce Mathias Nyman 2022-10-24 901 list_del_init(&dev->eps[i].bw_endpoint_list);
5aed5b7c2430ce Mathias Nyman 2022-10-24 902 xhci_dbg(xhci, "Slot %u endpoint %u not removed from BW list!\n",
2e27980e6eb781 Sarah Sharp 2011-09-02 903 slot_id, i);
8df75f42f8e67e Sarah Sharp 2010-04-02 904 }
5aed5b7c2430ce Mathias Nyman 2022-10-24 905 }
839c817ce67178 Sarah Sharp 2011-09-02 906 /* If this is a hub, free the TT(s) from the TT list */
839c817ce67178 Sarah Sharp 2011-09-02 907 xhci_free_tt_info(xhci, dev, slot_id);
2e27980e6eb781 Sarah Sharp 2011-09-02 908 /* If necessary, update the number of active TTs on this root port */
2e27980e6eb781 Sarah Sharp 2011-09-02 909 xhci_update_tt_active_eps(xhci, dev, old_active_eps);
3ffbba9511b414 Sarah Sharp 2009-04-27 910
3ffbba9511b414 Sarah Sharp 2009-04-27 911 if (dev->in_ctx)
d115b04818e57b John Youn 2009-07-27 912 xhci_free_container_ctx(xhci, dev->in_ctx);
3ffbba9511b414 Sarah Sharp 2009-04-27 @913 if (dev->out_ctx)
^^^^^^^^^^^^
Can dev->out_ctx be NULL?
d115b04818e57b John Youn 2009-07-27 914 xhci_free_container_ctx(xhci, dev->out_ctx);
d115b04818e57b John Youn 2009-07-27 915
a400efe455f7b6 Mathias Nyman 2018-03-16 916 if (dev->udev && dev->udev->slot_id)
a400efe455f7b6 Mathias Nyman 2018-03-16 917 dev->udev->slot_id = 0;
74151b5349266b Niklas Neronin 2024-02-29 918 if (dev->rhub_port && dev->rhub_port->slot_id == slot_id)
74151b5349266b Niklas Neronin 2024-02-29 919 dev->rhub_port->slot_id = 0;
0b5ed80150eb59 Weitao Wang 2025-07-30 920 if (xhci->devs[slot_id] == dev)
326b4810cc9952 Randy Dunlap 2010-04-19 921 xhci->devs[slot_id] = NULL;
0b5ed80150eb59 Weitao Wang 2025-07-30 922 kfree(dev);
3ffbba9511b414 Sarah Sharp 2009-04-27 923 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
prev parent reply other threads:[~2025-08-01 14:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 15:27 Weitao Wang
2025-08-01 13:06 ` Mathias Nyman
2025-08-01 14:31 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b5ab0f46-0fde-420e-97a2-136d3074b59c@suswa.mountain \
--to=dan.carpenter@linaro.org \
--cc=CobeChen@zhaoxin.com \
--cc=WeitaoWang-oc@zhaoxin.com \
--cc=WeitaoWang@zhaoxin.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mathias.nyman@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=wwt8723@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®