wait: fix loss of error code from waitid() when info is provided
One of the review comments on the original waitid patches suggested using the
pattern
ret = __put_user(...);
ret |= __put_user(...);
...
rather than
if (!ret)
ret = __put_user(...);
if (!ret)
ret |= __put_user(...);
This turns out to be a bad idea if ret is used for anything else first, e.g. if
it is used to store errnos from waitid(), since it overwrites any nonzero error
with the return value of __put_user(), even if that is zero.
The solution is to use a temporary error variable instead, and not assign it to
the actual return value if the temporary error variable is still zero after
doing all the __put_user()s (as is the common case).
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>