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

staging: comedi: fix sparse warning in do_devconfig_ioctl()

For the COMEDI_DEVCONFIG ioctl, the user application may embed a pointer
to firmware data within a designated element (or two elements for 64-bit
pointers) of the `options[]` array in the `struct comedi_devconfig`.
`do_devconfig_ioctl()` calls `comedi_aux_data()` to extract the pointer
value. It needs to be treated as a `__user` pointer so the firmware
data can be copied into kernel memory, so cast the result of
`comedi_aux_data()` to avoid a "sparse" warning. This is not ideal but
`comedi_aux_data()` is called elsewhere in a wholly kernel memory
context so we can't just change its return type to include the `__user`
tag.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ian Abbott and committed by
Greg Kroah-Hartman
dc881f29 0352b932

+2 -1
+2 -1
drivers/staging/comedi/comedi_fops.c
··· 370 370 return -ENOMEM; 371 371 372 372 if (copy_from_user(aux_data, 373 - comedi_aux_data(it.options, 0), aux_len)) { 373 + (unsigned char __user * 374 + )comedi_aux_data(it.options, 0), aux_len)) { 374 375 vfree(aux_data); 375 376 return -EFAULT; 376 377 }