[PATCH] Replacing simple_strtoul with kstrtoul

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Added code to move pointer till end of parsed string as being done by simple_strtoul. Not checking return value of kstrtoul
Signed-off-by: Asheesh Ranjan <asheesh.lkd@xxxxxxxxxxx>
---
 drivers/staging/speakup/varhandlers.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c
index 1b0d1c0..0e516cf 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -322,9 +322,22 @@ char *spk_strlwr(char *s)
 
 char *spk_s2uchar(char *start, char *dest)
 {
-	int val = 0;
+	long val = 0, val_copy;
+	int err;
+
+	err = kstrtoul(skip_spaces(start), 10, &val);
+
+	while (isspace(*start))
+		start++; /*Skip leading whitespace*/
+	val_copy = val*10;
+	while (val_copy != 0) { /* Keep track of number of digits left */
+		if (isdigit(*start)) {
+			val_copy /= 10;
+			start++; /* Move forward by a digit */
+		} else
+			break;
+	}
 
-	val = simple_strtoul(skip_spaces(start), &start, 10);
 	if (*start == ',')
 		start++;
 	*dest = (u_char)val;
-- 
1.7.10.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux