Re: [PATCH 1/2] staging: tidspbridge: replace strict_strtol() with kstrtol()

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

 



On Tuesday, July 23, 2013 8:03 PM, Dan Carpenter wrote:
> 
> The following test program illustrates the memory corruption.  You
> would hope foo.b would be 42 but it is corrupted to -1.
> 
> #include <stdio.h>
> #include <limits.h>
> 
> struct foo {
> 	int a, b;
> };
> 
> void kstrtol(long *x)
> {
> 	*x = -1;
> }
> 
> int main(void)
> {
> 	struct foo foo;
> 
> 	foo.b = 42;
> 	kstrtol((long *)&foo.a);
> 	printf("%d %d\n", foo.a, foo.b);
> 	return 0;
> }
> 
> The error handling should return an error, it shouldn't just print
> something.  It shouldn't print anything actually, it should just
> handle the error without printing or complaining.  :P

Oh, thank you very much.
Your comment is very kind. :)

I will use kstrtos32() instead of kstrtol() as below:

-	if (count >= 3)
-		strict_strtol(sz_last_token, 10, (long *)&req);
+	if (count >= 3) {
+		status = kstrtos32(sz_last_token, 10, &req);
+		if (status)
+			goto func_cont;
+	}

I really appreciate your comment.

Best regards,
Jingoo Han

_______________________________________________
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