All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jó Ágila Bitsch" <jgilab@gmail.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1 1/1] usg: gadget: Move validation out of lock in webusb_bcdVersion_store()
Date: Fri, 27 Jan 2023 13:26:38 +0200	[thread overview]
Message-ID: <20230127112638.84806-1-andriy.shevchenko@linux.intel.com> (raw)

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


                 reply	other threads:[~2023-01-27 11:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230127112638.84806-1-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jgilab@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.