linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	David Brownell <dbrownell@users.sourceforge.net>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-usb@vger.kernel.org
Subject: [PATCHv3 1/2] usb: gadget: storage: strict coversion of 'ro' parameter
Date: Thu, 15 Jul 2010 12:07:20 +0300	[thread overview]
Message-ID: <1279184841-15097-1-git-send-email-ext-andriy.shevchenko@nokia.com> (raw)
In-Reply-To: <op.vft7mxqm7p4s8u@pikus>

Bring a strict way to get the 'ro' parameter from the user.
The idea was discussed in LKML [1].

[1] http://lkml.org/lkml/2010/7/13/143

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-usb@vger.kernel.org
---
 drivers/usb/gadget/storage_common.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 04c462f..7123929 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -723,9 +723,9 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
 	ssize_t		rc = count;
 	struct fsg_lun	*curlun = fsg_lun_from_dev(dev);
 	struct rw_semaphore	*filesem = dev_get_drvdata(dev);
-	int		i;
+	unsigned long	ro;
 
-	if (sscanf(buf, "%d", &i) != 1)
+	if (strict_strtoul(buf, 2, &ro))
 		return -EINVAL;
 
 	/* Allow the write-enable status to change only while the backing file
@@ -735,8 +735,8 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
 		LDBG(curlun, "read-only status change prevented\n");
 		rc = -EBUSY;
 	} else {
-		curlun->ro = !!i;
-		curlun->initially_ro = !!i;
+		curlun->ro = ro;
+		curlun->initially_ro = ro;
 		LDBG(curlun, "read-only status set to %d\n", curlun->ro);
 	}
 	up_read(filesem);
-- 
1.6.3.3


  parent reply	other threads:[~2010-07-15  9:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-13  8:36 [PATCH] usb: gadget: storage: optional SCSI WRITE FUA bit Andy Shevchenko
2010-07-13 14:09 ` Alan Stern
2010-07-14  9:05   ` [PATCHv2] " Andy Shevchenko
2010-07-14 12:38     ` Michał Nazarewicz
2010-07-14 13:44       ` Andy Shevchenko
2010-07-14 13:55         ` Roger Quadros
2010-07-16  7:54           ` Felipe Balbi
2010-07-16  8:38             ` Roger Quadros
2010-07-14 14:24         ` Michał Nazarewicz
2010-07-14 15:05           ` Andy Shevchenko
2010-07-14 17:12             ` Michał Nazarewicz
2010-07-15  9:07           ` Andy Shevchenko [this message]
2010-07-15  9:07             ` [PATCHv3 2/2] " Andy Shevchenko
2010-07-21 19:17               ` Greg KH
2010-07-22  8:58                 ` [PATCHv4 1/2] usb: gadget: storage: strict coversion of 'ro' parameter Andy Shevchenko
2010-07-22  8:58                   ` [PATCHv4 2/2] usb: gadget: storage: optional SCSI WRITE FUA bit Andy Shevchenko
2010-07-22 14:13                     ` Alan Stern
2010-07-22 14:27                       ` Andy Shevchenko
2010-07-22 14:53                       ` [PATCHv5] " Andy Shevchenko
2010-07-22 14:07                   ` [PATCHv4 1/2] usb: gadget: storage: strict coversion of 'ro' parameter Alan Stern
2010-07-22 14:17                     ` Michał Nazarewicz
2010-07-21 19:17             ` [PATCHv3 " Greg KH

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=1279184841-15097-1-git-send-email-ext-andriy.shevchenko@nokia.com \
    --to=andy.shevchenko@gmail.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=ext-andriy.shevchenko@nokia.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).