]> www.infradead.org Git - users/jedix/linux-maple.git/commit
wait: fix loss of error code from waitid() when info is provided
authorNick Alcock <nick.alcock@oracle.com>
Mon, 22 Jul 2013 18:16:07 +0000 (19:16 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Tue, 21 Jul 2015 14:28:59 +0000 (15:28 +0100)
commitda2a4fa0dbb0e6603abea4868d67579bebc7d769
tree0b385c53e1bcec8300c6ca33fd32204bd7542048
parent90393f7bbb9eec67f459862f79f97de223cdb390
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>
kernel/exit.c