All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] usg: gadget: Move validation out of lock in webusb_bcdVersion_store()
@ 2023-01-27 11:26 Andy Shevchenko
  0 siblings, 0 replies; only message in thread
From: Andy Shevchenko @ 2023-01-27 11:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jó Ágila Bitsch, Andy Shevchenko,
	linux-usb, linux-kernel

Validation has nothing to do with any protected data,
move it out of the lock and make code neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/usb/gadget/configfs.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 63dc15b4f6d8..1346b330b358 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -836,19 +836,15 @@ static ssize_t webusb_bcdVersion_store(struct config_item *item,
 	if (ret)
 		return ret;
 
-	mutex_lock(&gi->lock);
-
 	ret = is_valid_bcd(bcdVersion);
 	if (ret)
-		goto out;
+		return ret;
 
+	mutex_lock(&gi->lock);
 	gi->bcd_webusb_version = bcdVersion;
-	ret = len;
-
-out:
 	mutex_unlock(&gi->lock);
 
-	return ret;
+	return len;
 }
 
 static ssize_t webusb_bVendorCode_show(struct config_item *item, char *page)
-- 
2.39.0


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

only message in thread, other threads:[~2023-01-27 11:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 11:26 [PATCH v1 1/1] usg: gadget: Move validation out of lock in webusb_bcdVersion_store() Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.