Skip to content

Commit fe6b186

Browse files
toddkjosgregkh
authored andcommitted
binder: fix handling of error during copy
If a memory copy function fails to copy the whole buffer, a positive integar with the remaining bytes is returned. In binder_translate_fd_array() this can result in an fd being skipped due to the failed copy, but the loop continues processing fds since the early return condition expects a negative integer on error. Fix by returning "ret > 0 ? -EINVAL : ret" to handle this case. Fixes: bb4a2e4 ("binder: return errors from buffer copy functions") Suggested-by: Dan Carpenter <[email protected]> Acked-by: Christian Brauner <[email protected]> Signed-off-by: Todd Kjos <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 690cfa2 commit fe6b186

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/android/binder.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,8 +2269,8 @@ static int binder_translate_fd_array(struct binder_fd_array_object *fda,
22692269
if (!ret)
22702270
ret = binder_translate_fd(fd, offset, t, thread,
22712271
in_reply_to);
2272-
if (ret < 0)
2273-
return ret;
2272+
if (ret)
2273+
return ret > 0 ? -EINVAL : ret;
22742274
}
22752275
return 0;
22762276
}

0 commit comments

Comments
 (0)