Skip to content

Commit

Permalink
staging: speakup: Use kstrtoul_from_user
Browse files Browse the repository at this point in the history
This patch replaces the code for getting an unsigned long from a
userspace buffer by a simple call to kstroul_from_user.
This makes it easier to read and less error prone.

Kernel Version: staging of 20110606

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Peter Huewe authored and Greg Kroah-Hartman committed Jun 28, 2011
1 parent 919ed52 commit 6263ba5
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions drivers/staging/speakup/speakup_soft.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,8 @@ static ssize_t softsynth_write(struct file *fp, const char *buf, size_t count,
{
unsigned long supplied_index = 0;
int converted;
char indbuf[5];
if (count >= sizeof(indbuf))
return -EINVAL;

if (copy_from_user(indbuf, buf, count))
return -EFAULT;
indbuf[count] = '\0';

converted = strict_strtoul(indbuf, 0, &supplied_index);
converted = kstrtoul_from_user(buf, count, 0, &supplied_index);

if (converted < 0)
return converted;
Expand Down

0 comments on commit 6263ba5

Please sign in to comment.