Re: [PATCH 2/2] usb: chipidea: udc: create bounce buffer for problem sglist entries if possible

Dan Carpenter
2024-10-09T14:47:23Z

Hi Xu,

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/Xu-Yang/usb-chipidea-udc-create-bounce-buffer-for-problem-sglist-entries-if-possible/20240912-125251
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link: https://lore.kernel.org/r/20240912045150.915573-2-xu.yang_2%40nxp.com
patch subject: [PATCH 2/2] usb: chipidea: udc: create bounce buffer for problem sglist entries if possible
config: i386-randconfig-141-20240914 (https://download.01.org/0day-ci/archive/20240914/202409141707.TOsGfePE-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 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/202409141707.TOsGfePE-lkp@intel.com/

New smatch warnings:
drivers/usb/chipidea/udc.c:704 _hardware_enqueue() error: uninitialized symbol 'bounced_size'.

vim +/bounced_size +704 drivers/usb/chipidea/udc.c

8e22978c57087a drivers/usb/chipidea/udc.c Alexander Shishkin 2013-06-24 671 static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo 2008-11-17 672 {
8e22978c57087a drivers/usb/chipidea/udc.c Alexander Shishkin 2013-06-24 673 struct ci_hdrc *ci = hwep->ci;
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18 674 int ret = 0;
cc9e6c495b0a37 drivers/usb/chipidea/udc.c Michael Grzeschik 2013-06-13 675 struct td_node *firstnode, *lastnode;
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 676 unsigned int bounced_size;
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 677 struct scatterlist *sg;
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo 2008-11-17 678
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo 2008-11-17 679 /* don't queue twice */
2dbc5c4c831418 drivers/usb/chipidea/udc.c Alexander Shishkin 2013-06-13 680 if (hwreq->req.status == -EALREADY)
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo 2008-11-17 681 return -EALREADY;
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo 2008-11-17 682
2dbc5c4c831418 drivers/usb/chipidea/udc.c Alexander Shishkin 2013-06-13 683 hwreq->req.status = -EALREADY;
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo 2008-11-17 684
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 685 if (hwreq->req.num_sgs && hwreq->req.length) {
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 686 ret = sglist_get_invalid_entry(ci->dev->parent, hwep->dir,
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 687 &hwreq->req);
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 688 if (ret < hwreq->req.num_sgs) {
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 689 ret = sglist_do_bounce(hwreq, ret, hwep->dir == TX,
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 690 &bounced_size);
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 691 if (ret)
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 692 return ret;
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 693 }
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 694 }

bounced_size not initialized on else path

91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 695
aeb78cda51005f drivers/usb/chipidea/udc.c Arnd Bergmann 2017-03-13 696 ret = usb_gadget_map_request_by_dev(ci->dev->parent,
aeb78cda51005f drivers/usb/chipidea/udc.c Arnd Bergmann 2017-03-13 697 &hwreq->req, hwep->dir);
5e0aa49ec61e88 drivers/usb/chipidea/udc.c Alexander Shishkin 2012-05-11 698 if (ret)
5e0aa49ec61e88 drivers/usb/chipidea/udc.c Alexander Shishkin 2012-05-11 699 return ret;
5e0aa49ec61e88 drivers/usb/chipidea/udc.c Alexander Shishkin 2012-05-11 700
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 701 if (hwreq->sgt.sgl) {
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 702 /* We've mapped a bigger buffer, now recover the actual size */
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 703 sg = sg_last(hwreq->req.sg, hwreq->req.num_sgs);
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 @704 sg_dma_len(sg) = min(sg_dma_len(sg), bounced_size);
^^^^^^^^^^^^

91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 705 }
91db40933ca942 drivers/usb/chipidea/udc.c Xu Yang 2024-09-12 706
e48aa1eb443f80 drivers/usb/chipidea/udc.c Peter Chen 2020-02-21 707 if (hwreq->req.num_mapped_sgs)
e48aa1eb443f80 drivers/usb/chipidea/udc.c Peter Chen 2020-02-21 708 ret = prepare_td_for_sg(hwep, hwreq);
e48aa1eb443f80 drivers/usb/chipidea/udc.c Peter Chen 2020-02-21 709 else

--
0-DAY CI Kernel Test Service