[bug report] usb: cdns3: change place of 'priv_ep' assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux