From: Douglas Gilbert <dgilbert@interlog.com>
To: akpm@linux-foundation.org
Cc: James.Bottomley@HansenPartnership.com,
linux-scsi@vger.kernel.org, sboyd@codeaurora.org
Subject: Re: [patch 4/6] drivers/scsi/sg.c: convert to kstrtoul_from_user()
Date: Thu, 12 Jan 2012 00:08:49 +1100 [thread overview]
Message-ID: <4F0D89E1.6060404@interlog.com> (raw)
In-Reply-To: <20120110234235.774BF200133@hpza10.eem.corp.google.com>
On 12-01-11 10:42 AM, akpm@linux-foundation.org wrote:
> From: Stephen Boyd<sboyd@codeaurora.org>
> Subject: drivers/scsi/sg.c: convert to kstrtoul_from_user()
>
> Instead of open coding this function use kstrtoul_from_user() directly.
>
> Signed-off-by: Stephen Boyd<sboyd@codeaurora.org>
> Cc: Doug Gilbert<dgilbert@interlog.com>
> Cc: Douglas Gilbert<dougg@torque.net>
> Cc: James Bottomley<James.Bottomley@HansenPartnership.com>
> Signed-off-by: Andrew Morton<akpm@linux-foundation.org>
Acked-by: Douglas Gilbert<dgilbert@interlog.com>
> ---
>
> drivers/scsi/sg.c | 25 +++++++++++--------------
> 1 file changed, 11 insertions(+), 14 deletions(-)
>
> diff -puN drivers/scsi/sg.c~drivers-scsi-sgc-convert-to-kstrtoul_from_user drivers/scsi/sg.c
> --- a/drivers/scsi/sg.c~drivers-scsi-sgc-convert-to-kstrtoul_from_user
> +++ a/drivers/scsi/sg.c
> @@ -2368,16 +2368,15 @@ static ssize_t
> sg_proc_write_adio(struct file *filp, const char __user *buffer,
> size_t count, loff_t *off)
> {
> - int num;
> - char buff[11];
> + int err;
> + unsigned long num;
>
> if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
> return -EACCES;
> - num = (count< 10) ? count : 10;
> - if (copy_from_user(buff, buffer, num))
> - return -EFAULT;
> - buff[num] = '\0';
> - sg_allow_dio = simple_strtoul(buff, NULL, 10) ? 1 : 0;
> + err = kstrtoul_from_user(buffer, count, 0,&num);
> + if (err)
> + return err;
> + sg_allow_dio = num ? 1 : 0;
> return count;
> }
>
> @@ -2390,17 +2389,15 @@ static ssize_t
> sg_proc_write_dressz(struct file *filp, const char __user *buffer,
> size_t count, loff_t *off)
> {
> - int num;
> + int err;
> unsigned long k = ULONG_MAX;
> - char buff[11];
>
> if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
> return -EACCES;
> - num = (count< 10) ? count : 10;
> - if (copy_from_user(buff, buffer, num))
> - return -EFAULT;
> - buff[num] = '\0';
> - k = simple_strtoul(buff, NULL, 10);
> +
> + err = kstrtoul_from_user(buffer, count, 0,&k);
> + if (err)
> + return err;
> if (k<= 1048576) { /* limit "big buff" to 1 MB */
> sg_big_buff = k;
> return count;
> _
>
next prev parent reply other threads:[~2012-01-11 13:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-10 23:42 [patch 4/6] drivers/scsi/sg.c: convert to kstrtoul_from_user() akpm
2012-01-11 0:08 ` James Bottomley
2012-01-11 0:12 ` Andrew Morton
2012-01-11 13:08 ` Douglas Gilbert [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-11-15 22:58 akpm
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=4F0D89E1.6060404@interlog.com \
--to=dgilbert@interlog.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=akpm@linux-foundation.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sboyd@codeaurora.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.