public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] USB: gadget: Fix return of -EBUSY
@ 2022-05-04 13:58 Colin Ian King
  2022-05-04 14:05 ` Alan Stern
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2022-05-04 13:58 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Alan Stern, linux-usb,
	linux-kernel
  Cc: kernel-janitors, llvm

Currently when driver->match_existing_only is true, the error return is
set to -EBUSY however ret is then set to 0 at the end of the if/else
statement. I believe the ret = 0 statement should be set in the else
part of the if statement and not at the end to ensure -EBUSY is being
returned correctly.

Detected by clang scan:
drivers/usb/gadget/udc/core.c:1558:4: warning: Value stored to 'ret' is
never read [deadcode.DeadStores]

Fixes: fc274c1e9973 ("USB: gadget: Add a new bus for gadgets")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 61790592b2c8..3281d8a3dae7 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1559,8 +1559,8 @@ int usb_gadget_register_driver_owner(struct usb_gadget_driver *driver,
 		} else {
 			pr_info("%s: couldn't find an available UDC\n",
 					driver->function);
+			ret = 0;
 		}
-		ret = 0;
 	}
 	mutex_unlock(&udc_lock);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-04 14:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-04 13:58 [PATCH][next] USB: gadget: Fix return of -EBUSY Colin Ian King
2022-05-04 14:05 ` Alan Stern

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