Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

binder: fix sparse issue in binder_alloc_selftest.c

Fixes sparse issues reported by the kbuild test robot running
on https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
char-misc-testing: bde4a19fc04f5 ("binder: use userspace pointer as base
of buffer space")

Error output (drivers/android/binder_alloc_selftest.c):
sparse: warning: incorrect type in assignment (different address spaces)
sparse: expected void *page_addr
sparse: got void [noderef] <asn:1> *user_data
sparse: error: subtraction of different types can't work

Fixed by adding necessary "__user" tags.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Todd Kjos <tkjos@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Todd Kjos and committed by
Greg Kroah-Hartman
36f30937 ca5dc2d1

+3 -2
+3 -2
drivers/android/binder_alloc_selftest.c
··· 102 102 struct binder_buffer *buffer, 103 103 size_t size) 104 104 { 105 - void *page_addr, *end; 105 + void __user *page_addr; 106 + void __user *end; 106 107 int page_index; 107 108 108 - end = (void *)PAGE_ALIGN((uintptr_t)buffer->user_data + size); 109 + end = (void __user *)PAGE_ALIGN((uintptr_t)buffer->user_data + size); 109 110 page_addr = buffer->user_data; 110 111 for (; page_addr < end; page_addr += PAGE_SIZE) { 111 112 page_index = (page_addr - alloc->buffer) / PAGE_SIZE;