public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: mmc_test: replace strict_strtol() with kstrtol_from_user()
@ 2013-07-19  7:02 Jingoo Han
  2013-08-25  3:19 ` Chris Ball
  0 siblings, 1 reply; 2+ messages in thread
From: Jingoo Han @ 2013-07-19  7:02 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Jingoo Han

The usage of strict_strtol() is not preferred, because
strict_strtol() is obsolete. Thus, kstrtol() should be
used.

Also, both kstrtol() and copy_from_user() can be replaced
with kstrtol_from_user() to make the code simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/mmc/card/mmc_test.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index a69df52..0c0fc52 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -2849,18 +2849,12 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,
 	struct seq_file *sf = (struct seq_file *)file->private_data;
 	struct mmc_card *card = (struct mmc_card *)sf->private;
 	struct mmc_test_card *test;
-	char lbuf[12];
 	long testcase;
+	int ret;
 
-	if (count >= sizeof(lbuf))
-		return -EINVAL;
-
-	if (copy_from_user(lbuf, buf, count))
-		return -EFAULT;
-	lbuf[count] = '\0';
-
-	if (strict_strtol(lbuf, 10, &testcase))
-		return -EINVAL;
+	ret = kstrtol_from_user(buf, count, 10, &testcase);
+	if (ret)
+		return ret;
 
 	test = kzalloc(sizeof(struct mmc_test_card), GFP_KERNEL);
 	if (!test)
-- 
1.7.10.4



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

* Re: [PATCH] mmc: mmc_test: replace strict_strtol() with kstrtol_from_user()
  2013-07-19  7:02 [PATCH] mmc: mmc_test: replace strict_strtol() with kstrtol_from_user() Jingoo Han
@ 2013-08-25  3:19 ` Chris Ball
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Ball @ 2013-08-25  3:19 UTC (permalink / raw)
  To: Jingoo Han; +Cc: linux-mmc

Hi Jingoo,

On Fri, Jul 19 2013, Jingoo Han wrote:
> The usage of strict_strtol() is not preferred, because
> strict_strtol() is obsolete. Thus, kstrtol() should be
> used.
>
> Also, both kstrtol() and copy_from_user() can be replaced
> with kstrtol_from_user() to make the code simpler.
>
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> ---
>  drivers/mmc/card/mmc_test.c |   14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
> index a69df52..0c0fc52 100644
> --- a/drivers/mmc/card/mmc_test.c
> +++ b/drivers/mmc/card/mmc_test.c
> @@ -2849,18 +2849,12 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,
>  	struct seq_file *sf = (struct seq_file *)file->private_data;
>  	struct mmc_card *card = (struct mmc_card *)sf->private;
>  	struct mmc_test_card *test;
> -	char lbuf[12];
>  	long testcase;
> +	int ret;
>  
> -	if (count >= sizeof(lbuf))
> -		return -EINVAL;
> -
> -	if (copy_from_user(lbuf, buf, count))
> -		return -EFAULT;
> -	lbuf[count] = '\0';
> -
> -	if (strict_strtol(lbuf, 10, &testcase))
> -		return -EINVAL;
> +	ret = kstrtol_from_user(buf, count, 10, &testcase);
> +	if (ret)
> +		return ret;
>  
>  	test = kzalloc(sizeof(struct mmc_test_card), GFP_KERNEL);
>  	if (!test)

Thanks, pushed to mmc-next for 3.12.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>

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

end of thread, other threads:[~2013-08-25  3:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-19  7:02 [PATCH] mmc: mmc_test: replace strict_strtol() with kstrtol_from_user() Jingoo Han
2013-08-25  3:19 ` Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox