linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] s390/sclp_async: Use kstrtoul_from_user
@ 2011-06-06 21:07 Peter Huewe
  2011-06-06 21:07 ` [PATCH 2/2] s390/qdio_debug: " Peter Huewe
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Huewe @ 2011-06-06 21:07 UTC (permalink / raw)
  To: Martin Schwidefsky, linux390
  Cc: Heiko Carstens, Peter Huewe, Jan Glauber, David S. Miller,
	Frank Blaschka, linux-s390, linux-kernel, kernel-janitors

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: v3.0-rc2

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/s390/char/sclp_async.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/s390/char/sclp_async.c b/drivers/s390/char/sclp_async.c
index 7ad30e7..012d1a8 100644
--- a/drivers/s390/char/sclp_async.c
+++ b/drivers/s390/char/sclp_async.c
@@ -82,12 +82,10 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write,
 			return -EFAULT;
 	} else {
 		len = *count;
-		rc = copy_from_user(buf, buffer, sizeof(buf));
-		if (rc != 0)
-			return -EFAULT;
-		buf[sizeof(buf) - 1] = '\0';
-		if (strict_strtoul(buf, 0, &val) != 0)
-			return -EINVAL;
+		rc = kstrtoul_from_user(buffer, len, 0, &val);
+		if (rc)
+			return rc;
+
 		if (val != 0 && val != 1)
 			return -EINVAL;
 		callhome_enabled = val;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] s390/qdio_debug: Use kstrtoul_from_user
  2011-06-06 21:07 [PATCH 1/2] s390/sclp_async: Use kstrtoul_from_user Peter Huewe
@ 2011-06-06 21:07 ` Peter Huewe
  2011-06-07 10:27   ` Jan Glauber
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Huewe @ 2011-06-06 21:07 UTC (permalink / raw)
  To: Martin Schwidefsky, linux390
  Cc: Heiko Carstens, Peter Huewe, Jan Glauber, David S. Miller,
	Frank Blaschka, linux-s390, linux-kernel, kernel-janitors

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: v3.0-rc2

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/s390/cio/qdio_debug.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c
index f8b03a6..0e615cb 100644
--- a/drivers/s390/cio/qdio_debug.c
+++ b/drivers/s390/cio/qdio_debug.c
@@ -188,19 +188,13 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,
 	struct qdio_irq *irq_ptr = seq->private;
 	struct qdio_q *q;
 	unsigned long val;
-	char buf[8];
 	int ret, i;
 
 	if (!irq_ptr)
 		return 0;
-	if (count >= sizeof(buf))
-		return -EINVAL;
-	if (copy_from_user(&buf, ubuf, count))
-		return -EFAULT;
-	buf[count] = 0;
-
-	ret = strict_strtoul(buf, 10, &val);
-	if (ret < 0)
+
+	ret = kstrtoul_from_user(ubuf, count, 10, &val);
+	if (ret)
 		return ret;
 
 	switch (val) {
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] s390/qdio_debug: Use kstrtoul_from_user
  2011-06-06 21:07 ` [PATCH 2/2] s390/qdio_debug: " Peter Huewe
@ 2011-06-07 10:27   ` Jan Glauber
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Glauber @ 2011-06-07 10:27 UTC (permalink / raw)
  To: Peter Huewe
  Cc: Martin Schwidefsky, linux390, Heiko Carstens, David S. Miller,
	Frank Blaschka, linux-s390, linux-kernel, kernel-janitors

On Mon, Jun 06, 2011 at 11:07:54PM +0200, Peter Huewe wrote:
> 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: v3.0-rc2
> 
> Signed-off-by: Peter Huewe <peterhuewe@gmx.de>

Acked-by: Jan Glauber <jang@linux.vnet.ibm.com>

> ---
>  drivers/s390/cio/qdio_debug.c |   12 +++---------
>  1 files changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c
> index f8b03a6..0e615cb 100644
> --- a/drivers/s390/cio/qdio_debug.c
> +++ b/drivers/s390/cio/qdio_debug.c
> @@ -188,19 +188,13 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,
>  	struct qdio_irq *irq_ptr = seq->private;
>  	struct qdio_q *q;
>  	unsigned long val;
> -	char buf[8];
>  	int ret, i;
> 
>  	if (!irq_ptr)
>  		return 0;
> -	if (count >= sizeof(buf))
> -		return -EINVAL;
> -	if (copy_from_user(&buf, ubuf, count))
> -		return -EFAULT;
> -	buf[count] = 0;
> -
> -	ret = strict_strtoul(buf, 10, &val);
> -	if (ret < 0)
> +
> +	ret = kstrtoul_from_user(ubuf, count, 10, &val);
> +	if (ret)
>  		return ret;
> 
>  	switch (val) {
> -- 
> 1.7.3.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-07 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-06 21:07 [PATCH 1/2] s390/sclp_async: Use kstrtoul_from_user Peter Huewe
2011-06-06 21:07 ` [PATCH 2/2] s390/qdio_debug: " Peter Huewe
2011-06-07 10:27   ` Jan Glauber

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).