[PATCHv5 2/3] mmc_test: change simple_strtol() to strict_strtol()

From: Andy Shevchenko
Date: Mon Sep 06 2010 - 04:12:11 EST


It's better to use strict_strtol() to convert user's input and strictly check
it. At least it forbids to interpret wrong input as a 0 and prevents to run all
tests.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@xxxxxxxxx>
---
drivers/mmc/card/mmc_test.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index cd8edf4..6bffb33 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -1937,9 +1937,10 @@ static ssize_t mmc_test_store(struct device *dev,
{
struct mmc_card *card = mmc_dev_to_card(dev);
struct mmc_test_card *test;
- int testcase;
+ long testcase;

- testcase = simple_strtol(buf, NULL, 10);
+ if (strict_strtol(buf, 10, &testcase))
+ return -EINVAL;

test = kzalloc(sizeof(struct mmc_test_card), GFP_KERNEL);
if (!test)
--
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/