Skip to content

Commit d464dac

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
usb: gadget: fsl: Initialize udc before using it
fsl_ep_queue() is only called by usb_ep_queue() (as ep->ops->queue()). So _ep isn't NULL. As ep->ops->queue = fsl_ep_queue, the ep was initialized by struct_ep_setup() and so ep->udc isn't NULL either. Drop the check for _ep being NULL and assign udc earlier to prevent following an uninitialized pointer in the two dev_vdbg()s in lines 878 and 882. This fixes a compiler warning when using clang and CONFIG_USB_GADGET_VERBOSE=y. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202404050227.TTvcCPBu-lkp@intel.com/ Fixes: 6025f20 ("usb: gadget: fsl-udc: Replace custom log wrappers by dev_{err,warn,dbg,vdbg}") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20240405055812.694123-2-u.kleine-koenig@pengutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d920a2e commit d464dac

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/usb/gadget/udc/fsl_udc_core.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
868868
{
869869
struct fsl_ep *ep = container_of(_ep, struct fsl_ep, ep);
870870
struct fsl_req *req = container_of(_req, struct fsl_req, req);
871-
struct fsl_udc *udc;
871+
struct fsl_udc *udc = ep->udc;
872872
unsigned long flags;
873873
int ret;
874874

@@ -878,7 +878,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
878878
dev_vdbg(&udc->gadget.dev, "%s, bad params\n", __func__);
879879
return -EINVAL;
880880
}
881-
if (unlikely(!_ep || !ep->ep.desc)) {
881+
if (unlikely(!ep->ep.desc)) {
882882
dev_vdbg(&udc->gadget.dev, "%s, bad ep\n", __func__);
883883
return -EINVAL;
884884
}
@@ -887,7 +887,6 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
887887
return -EMSGSIZE;
888888
}
889889

890-
udc = ep->udc;
891890
if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN)
892891
return -ESHUTDOWN;
893892

0 commit comments

Comments
 (0)