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

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

 



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

regards,
dan carpenter

_______________________________________________
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