public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] usb: host: xhci-mem: Allow for interrupter clients to choose specific index
@ 2025-04-15 10:11 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2025-04-15 10:11 UTC (permalink / raw)
  To: Wesley Cheng; +Cc: linux-usb

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

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

only message in thread, other threads:[~2025-04-15 10:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 10:11 [bug report] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox