Messages in this thread | | | From | Linus Torvalds <> | Date | Sun, 27 Dec 2020 09:42:06 -0800 | Subject | Re: [GIT PULL] NTB bug fixes for v5.11 |
| |
On Sun, Dec 27, 2020 at 9:38 AM Linus Torvalds <torvalds@linux-foundation.org> wrote: > > The thing is, "PTR_ERR()" works just fine on a IS_ERR_OR_NULL pointer. > It doesn't work on a _regular_ non-NULL and non-ERR pointer, and will > return random garbage for those. But if you've tested for > IS_ERR_OR_NULL(), then a regular PTR_ERR() is already fine.
Side note: no, standard C does not guarantee that a NULL pointer would cast to the integer 0 (despite a cast of the constant 0 turning into NULL), but the kernel very much does. And our ERR_PTR() games in particular already violate all the standard C rules, and we very much depend on the pointer bit patterns to begin with.
Linus
| |