public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: linux-usb@vger.kernel.org
Subject: [bug report] usb: host: xhci-mem: Allow for interrupter clients to choose specific index
Date: Tue, 15 Apr 2025 13:11:37 +0300	[thread overview]
Message-ID: <Z_4w2b0BMiaCHqUx@stanley.mountain> (raw)

Hello Wesley Cheng,

Commit fce57295497d ("usb: host: xhci-mem: Allow for interrupter
clients to choose specific index") from Apr 9, 2025 (linux-next),
leads to the following Smatch static checker warning:

	drivers/usb/host/xhci-mem.c:2373 xhci_create_secondary_interrupter()
	error: uninitialized symbol 'i'.

drivers/usb/host/xhci-mem.c
  2333  xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs,
  2334                                    u32 imod_interval, unsigned int intr_num)
  2335  {
  2336          struct xhci_hcd *xhci = hcd_to_xhci(hcd);
  2337          struct xhci_interrupter *ir;
  2338          unsigned int i;
  2339          int err = -ENOSPC;
  2340  
  2341          if (!xhci->interrupters || xhci->max_interrupters <= 1 ||
  2342              intr_num >= xhci->max_interrupters)
  2343                  return NULL;
  2344  
  2345          ir = xhci_alloc_interrupter(xhci, segs, GFP_KERNEL);
  2346          if (!ir)
  2347                  return NULL;
  2348  
  2349          spin_lock_irq(&xhci->lock);
  2350          if (!intr_num) {
  2351                  /* Find available secondary interrupter, interrupter 0 is reserved for primary */
  2352                  for (i = 1; i < xhci->max_interrupters; i++) {
  2353                          if (!xhci->interrupters[i]) {
  2354                                  err = xhci_add_interrupter(xhci, ir, i);
  2355                                  break;
  2356                          }
  2357                  }
  2358          } else {
  2359                  if (!xhci->interrupters[intr_num])
  2360                          err = xhci_add_interrupter(xhci, ir, intr_num);

i not initialized on this path

  2361          }
  2362          spin_unlock_irq(&xhci->lock);
  2363  
  2364          if (err) {
  2365                  xhci_warn(xhci, "Failed to add secondary interrupter, max interrupters %d\n",
  2366                            xhci->max_interrupters);
  2367                  xhci_free_interrupter(xhci, ir);
  2368                  return NULL;
  2369          }
  2370  
  2371          err = xhci_set_interrupter_moderation(ir, imod_interval);
  2372          if (err)
  2373                  xhci_warn(xhci, "Failed to set interrupter %d moderation to %uns\n",
  2374                            i, imod_interval);
                                  ^

  2375  
  2376          xhci_dbg(xhci, "Add secondary interrupter %d, max interrupters %d\n",
  2377                   ir->intr_num, xhci->max_interrupters);
  2378  
  2379          return ir;
  2380  }

regards,
dan carpenter

                 reply	other threads:[~2025-04-15 10:11 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=Z_4w2b0BMiaCHqUx@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=quic_wcheng@quicinc.com \
    /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