RE: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls
From: David Laight
Date: Tue Oct 01 2019 - 10:36:23 EST
> From: Dan Carpenter
> Sent: 01 October 2019 14:57
> Subject: Re: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls
...
> That's true for glibc memcpy() but not for the kernel memcpy(). In the
> kernel there are lots of places which do a zero size memcpy().
And probably from NULL (or even garbage) pointers.
After all a pointer to the end of an array (a + ARRAY_SIZE(a)) is valid
but must not be dereferenced - so memcpy() can't dereference it's
source address when the length is zero.
> The glibc attitude is "the standard allows us to put knives here" so
> let's put knives everywhere in the path. And the GCC attitude is let's
> silently remove NULL checks instead of just printing a warning that the
> NULL check isn't required... It could really make someone despondent.
gcc is the one that add knives...
This reminds me of me of a compiler that decided to optimise away
checks for function addresses being NULL.
At almost exactly the same time that ELF allowed for undefined weak symbols.
Checking whether a function was actually present was non-trivial.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)