Skip to content

Commit

Permalink
usb: gadget: storage: strict coversion of 'ro' parameter
Browse files Browse the repository at this point in the history
Bring a strict way to get the 'ro' parameter from the user.

The patch followed by this one adds another boolean parameter. To be consistent
Michał Nazarewicz proposed to use simple_strtol() in both cases (correspondend
discussion in LKML [1]). Due to simple_strtol() doesn't return error in a good
way and we have a boolean parameter the strict_strtoul() is used.

[1] http://lkml.org/lkml/2010/7/14/169

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Andy Shevchenko authored and Greg Kroah-Hartman committed Aug 10, 2010
1 parent 787f4e5 commit 8156d15
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/usb/gadget/storage_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,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;

/*
Expand All @@ -762,8 +762,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);
Expand Down

0 comments on commit 8156d15

Please sign in to comment.