Re:“People who implement new and improved interfaces always ...
by thomasahle on Friday September 11, 2015 @12:59PM
(#10204788)
I see. And the previous code didn't have this issue?
Re:“People who implement new and improved interfaces always ...
by metric10 on Friday September 11, 2015 @04:06PM
(#10205872)
I don't know about Linux's simple_strtoul(), but the C library's strtoul(3) will return ULONG_MAX and set the string pointer to a valid location. So the old code COULD cause an issue if "io_tlb_nslabs" being equal to ULONG_MAX isn't accounted for later on, but adding -1 (0xffffffffffffffff) to a pointer (as the new code does) is far worse.
Re:“People who implement new and improved interfaces always ...
by sanderjd on Friday September 11, 2015 @02:39PM
(#10205412)
Haven't read any of the relevant code, but if the new code returns a negative number representing an error, it will decrement the `str` pointer, whereas I'm guessing `simple_strtoul` leaves its `str` pointer alone on error.
The function returns either a positive number indicating the number of characters successfully read from the string (if it encountered a non-digit character) or a negative number indicating an error code.
https://lwn.net/Articles/643159/