linux/drivers/usb
Nathan Chancellor 78acd4ca43 usb: cdns3: Don't use priv_dev uninitialized in cdns3_gadget_ep_enable()
Clang warns:

  drivers/usb/cdns3/cdns3-gadget.c:2290:11: error: variable 'priv_dev' is uninitialized when used here [-Werror,-Wuninitialized]
                  dev_dbg(priv_dev->dev, "usbss: invalid parameters\n");
                          ^~~~~~~~
  include/linux/dev_printk.h:155:18: note: expanded from macro 'dev_dbg'
          dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
                          ^~~
  include/linux/dynamic_debug.h:167:7: note: expanded from macro 'dynamic_dev_dbg'
                          dev, fmt, ##__VA_ARGS__)
                          ^~~
  include/linux/dynamic_debug.h:152:56: note: expanded from macro '_dynamic_func_call'
          __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
                                                              ^~~~~~~~~~~
  include/linux/dynamic_debug.h:134:15: note: expanded from macro '__dynamic_func_call'
                  func(&id, ##__VA_ARGS__);               \
                              ^~~~~~~~~~~
  drivers/usb/cdns3/cdns3-gadget.c:2278:31: note: initialize the variable 'priv_dev' to silence this warning
          struct cdns3_device *priv_dev;
                                      ^
                                      = NULL
  1 error generated.

The priv_dev assignment was moved below the if statement to avoid
potentially dereferencing ep before it was checked but priv_dev is used
in the dev_dbg() call.

To fix this, move the priv_dev and comp_desc assignments back to their
original spot and hoist the ep check above those assignments with a call
to pr_debug() instead of dev_dbg().

Fixes: c3ffc9c4ca ("usb: cdns3: change place of 'priv_ep' assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable()")
Link: https://github.com/ClangBuiltLinux/linux/issues/1680
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-08-04 11:53:48 -07:00
..
atm usb/atm: fix repeated words in comments 2022-07-27 14:32:20 +02:00
c67x00 USB: c67x00: remove unnecessary check of res 2022-05-12 11:36:46 +02:00
cdns3 usb: cdns3: Don't use priv_dev uninitialized in cdns3_gadget_ep_enable() 2022-08-04 11:53:48 -07:00
chipidea usb/chipidea: fix repeated words in comments 2022-07-27 14:38:01 +02:00
class USB: cdc-acm: use CDC serial-state defines 2022-07-25 10:57:41 +02:00
common usb: common: usb-conn-gpio: Allow wakeup from system suspend 2022-06-10 11:48:41 +02:00
core USB / Thunderbolt changes for 6.0-rc1 2022-08-04 11:41:28 -07:00
dwc2 usb: dwc2: drop unexpected word "the" in the comments 2022-06-24 13:37:34 +02:00
dwc3 Merge 5.19-rc7 into usb-next 2022-07-18 22:41:42 +02:00
early usb: early: xhci-dbc: Fix xdbc number parsing 2022-03-15 18:20:34 +01:00
gadget USB: gadget: Fix use-after-free Read in usb_udc_uevent() 2022-07-27 14:31:37 +02:00
host usb: renesas-xhci: Do not print any log while fw verif success 2022-07-27 14:37:48 +02:00
image usb/image: fix repeated words in comments 2022-07-27 14:33:53 +02:00
isp1760 usb: isp1760: Fix out-of-bounds array access 2022-05-19 18:10:59 +02:00
misc usb: misc: onboard_usb_hub: Remove duplicated power_on delay 2022-07-28 09:21:15 +02:00
mon
mtu3 usb: mtu3: support function remote wakeup 2022-07-08 14:53:30 +02:00
musb usb/musb: fix repeated words in comments 2022-07-27 14:34:05 +02:00
phy usb: phy: remove redundant store to variable var after & operation 2022-07-27 14:24:50 +02:00
renesas_usbhs usb: renesas: Fix refcount leak bug 2022-06-21 16:39:03 +02:00
roles
serial USB-serial updates for 5.20-rc1 2022-07-25 11:28:52 +02:00
storage USB: storage: Fix typo in comment 2022-06-21 16:39:42 +02:00
typec usb: typec: ucsi: stm32g0: add bootloader support 2022-07-27 14:39:11 +02:00
usbip usbip: vudc: Don't enable IRQs prematurely 2022-06-10 11:48:19 +02:00
Kconfig usb: remove reference to deleted config STB03xxx 2021-08-18 15:32:19 +02:00
Makefile usb: host: remove line for obsolete config USB_HWA_HCD 2021-08-18 15:32:19 +02:00
usb-skeleton.c usb: usb-skeleton: Update min() to min_t() 2021-10-05 12:56:48 +02:00