All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] usb: cdns3: change place of 'priv_ep' assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable()
@ 2022-08-04  8:21 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-08-04  8:21 UTC (permalink / raw)
  To: strochuk; +Cc: linux-usb

Hello Andrey Strachuk,

The patch c3ffc9c4ca44: "usb: cdns3: change place of 'priv_ep'
assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable()"
from Jul 18, 2022, leads to the following Smatch static checker
warning:

	drivers/usb/cdns3/cdns3-gadget.c:2290 cdns3_gadget_ep_enable()
	error: potentially dereferencing uninitialized 'priv_dev'.

drivers/usb/cdns3/cdns3-gadget.c
    2274 static int cdns3_gadget_ep_enable(struct usb_ep *ep,
    2275                                   const struct usb_endpoint_descriptor *desc)
    2276 {
    2277         struct cdns3_endpoint *priv_ep;
    2278         struct cdns3_device *priv_dev;
    2279         const struct usb_ss_ep_comp_descriptor *comp_desc;
    2280         u32 reg = EP_STS_EN_TRBERREN;
    2281         u32 bEndpointAddress;
    2282         unsigned long flags;
    2283         int enable = 1;
    2284         int ret = 0;
    2285         int val;
    2286 
    2287         priv_ep = ep_to_cdns3_ep(ep);
    2288 
    2289         if (!ep || !desc || desc->bDescriptorType != USB_DT_ENDPOINT) {
--> 2290                 dev_dbg(priv_dev->dev, "usbss: invalid parameters\n");
                                 ^^^^^^^^
Uninitialized.

    2291                 return -EINVAL;
    2292         }
    2293 
    2294         comp_desc = priv_ep->endpoint.comp_desc;
    2295         priv_dev = priv_ep->cdns3_dev;
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Initalized here.

The commit should be reverted.  The fix for those static checker
warnings is to delete the NULL checks on "ep" and "desc".

    2296 
    2297         if (!desc->wMaxPacketSize) {
    2298                 dev_err(priv_dev->dev, "usbss: missing wMaxPacketSize\n");
    2299                 return -EINVAL;
    2300         }
    2301 

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-04  8:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04  8:21 [bug report] usb: cdns3: change place of 'priv_ep' assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable() Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.