WSL2-Linux-Kernel/drivers/usb
Nathan Chancellor 0edd9f8d13 usb: cdns3: Don't use priv_dev uninitialized in cdns3_gadget_ep_enable()
[ Upstream commit 78acd4ca43 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-17 14:24:01 +02:00
..
atm
c67x00
cdns3 usb: cdns3: Don't use priv_dev uninitialized in cdns3_gadget_ep_enable() 2022-08-17 14:24:01 +02:00
chipidea usb: chipidea: udc: check request status before setting device address 2022-06-29 09:03:27 +02:00
class
common
core USB: HCD: Fix URB giveback issue in tasklet function 2022-08-17 14:22:58 +02:00
dwc2 usb: dwc2: Fix memory leak in dwc2_hcd_init 2022-06-22 14:22:03 +02:00
dwc3 usb: dwc3: qcom: fix missing optional irq warnings 2022-08-17 14:23:52 +02:00
early
gadget usb: aspeed-vhub: Fix refcount leak bug in ast_vhub_init_desc() 2022-08-17 14:23:52 +02:00
host usb: host: xhci: use snprintf() in xhci_decode_trb() 2022-08-17 14:23:46 +02:00
image
isp1760 usb: isp1760: Fix out-of-bounds array access 2022-06-09 10:22:27 +02:00
misc
mon
mtu3
musb usb: musb: Fix missing of_node_put() in omap2430_probe 2022-06-14 18:36:04 +02:00
phy extcon: Fix extcon_get_extcon_dev() error handling 2022-06-14 18:36:21 +02:00
renesas_usbhs
roles
serial USB: serial: fix tty-port initialized comments 2022-08-17 14:23:57 +02:00
storage USB: storage: karma: fix rio_karma_init return 2022-06-14 18:36:04 +02:00
typec usb: typec: ucsi: Acknowledge the GET_ERROR_STATUS command completion 2022-08-17 14:22:58 +02:00
usbip usb: usbip: add missing device lock on tweak configuration cmd 2022-06-14 18:36:04 +02:00
Kconfig
Makefile
usb-skeleton.c