drivers/usb/gadget/udc/fsl_udc_core.c:878:13: warning: variable 'udc' is uninitialized when used here

From: kernel test robot
Date: Thu Apr 04 2024 - 15:00:15 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c85af715cac0a951eea97393378e84bb49384734
commit: 6025f20f16c25d262680f6e1040d4bcdc0ecd0f3 usb: gadget: fsl-udc: Replace custom log wrappers by dev_{err,warn,dbg,vdbg}
date: 4 weeks ago
config: powerpc-randconfig-002-20240405 (https://download.01.org/0day-ci/archive/20240405/202404050227.TTvcCPBu-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240405/202404050227.TTvcCPBu-lkp@xxxxxxxxx/reproduce)

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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202404050227.TTvcCPBu-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> drivers/usb/gadget/udc/fsl_udc_core.c:878:13: warning: variable 'udc' is uninitialized when used here [-Wuninitialized]
dev_vdbg(&udc->gadget.dev, "%s, bad params\n", __func__);
^~~
include/linux/dev_printk.h:257:18: note: expanded from macro 'dev_vdbg'
#define dev_vdbg dev_dbg
^
include/linux/dev_printk.h:155:18: note: expanded from macro 'dev_dbg'
dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
^~~
include/linux/dynamic_debug.h:274:7: note: expanded from macro 'dynamic_dev_dbg'
dev, fmt, ##__VA_ARGS__)
^~~
include/linux/dynamic_debug.h:250:59: note: expanded from macro '_dynamic_func_call'
_dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/dynamic_debug.h:248:65: note: expanded from macro '_dynamic_func_call_cls'
__dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/dynamic_debug.h:224:15: note: expanded from macro '__dynamic_func_call_cls'
func(&id, ##__VA_ARGS__); \
^~~~~~~~~~~
drivers/usb/gadget/udc/fsl_udc_core.c:871:21: note: initialize the variable 'udc' to silence this warning
struct fsl_udc *udc;
^
= NULL
1 warning generated.


vim +/udc +878 drivers/usb/gadget/udc/fsl_udc_core.c

864
865 /* queues (submits) an I/O request to an endpoint */
866 static int
867 fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
868 {
869 struct fsl_ep *ep = container_of(_ep, struct fsl_ep, ep);
870 struct fsl_req *req = container_of(_req, struct fsl_req, req);
871 struct fsl_udc *udc;
872 unsigned long flags;
873 int ret;
874
875 /* catch various bogus parameters */
876 if (!_req || !req->req.complete || !req->req.buf
877 || !list_empty(&req->queue)) {
> 878 dev_vdbg(&udc->gadget.dev, "%s, bad params\n", __func__);
879 return -EINVAL;
880 }
881 if (unlikely(!_ep || !ep->ep.desc)) {
882 dev_vdbg(&udc->gadget.dev, "%s, bad ep\n", __func__);
883 return -EINVAL;
884 }
885 if (usb_endpoint_xfer_isoc(ep->ep.desc)) {
886 if (req->req.length > ep->ep.maxpacket)
887 return -EMSGSIZE;
888 }
889
890 udc = ep->udc;
891 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN)
892 return -ESHUTDOWN;
893
894 req->ep = ep;
895
896 ret = usb_gadget_map_request(&ep->udc->gadget, &req->req, ep_is_in(ep));
897 if (ret)
898 return ret;
899
900 req->req.status = -EINPROGRESS;
901 req->req.actual = 0;
902 req->dtd_count = 0;
903
904 /* build dtds and push them to device queue */
905 if (!fsl_req_to_dtd(req, gfp_flags)) {
906 spin_lock_irqsave(&udc->lock, flags);
907 fsl_queue_td(ep, req);
908 } else {
909 return -ENOMEM;
910 }
911
912 /* irq handler advances the queue */
913 if (req != NULL)
914 list_add_tail(&req->queue, &ep->queue);
915 spin_unlock_irqrestore(&udc->lock, flags);
916
917 return 0;
918 }
919

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki