Linux USB
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: strochuk@ispras.ru
Cc: linux-usb@vger.kernel.org
Subject: [bug report] usb: cdns3: change place of 'priv_ep' assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable()
Date: Thu, 4 Aug 2022 11:21:06 +0300	[thread overview]
Message-ID: <YuuBcg8LzwdGu6Ht@kili> (raw)

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

                 reply	other threads:[~2022-08-04  8:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YuuBcg8LzwdGu6Ht@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=strochuk@ispras.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox