• H Hartley Sweeten's avatar
    staging: comedi: kcomedilib: fix a __user space access issue · 1f5cc359
    H Hartley Sweeten authored
    The 'data' field in struct comedi_insn is an unsigned int __user *.
    The comedi core copies this data to kernel space before passing it
    on to a drivers insn_bits/insn_config method.
    
    kcomedilib provides an interface for external kernel modules to
    use the comedi drivers. This interface creates a comedi_insn
    that is then passed to the comedi drivers insn_bits/insn_config
    method. Unfortunately, kcomedilib is using the comedi_insn 'data'
    field directly which results in some sparse warnings:
    
      warning: incorrect type in argument 4 (different address spaces)
         expected unsigned int *<noident>
         got unsigned int [noderef] <asn:1>*data
    
      warning: incorrect type in assignment (different address spaces)
         expected unsigned int [noderef] <asn:1>*[addressable] [assigned] data
         got unsigned int *<noident>
    
    Fix this by passing the kernel data directly, as a separate parameter,
    instead of trying to put in into the comedi_insn 'data' field. This is
    how the comedi core handles the data from user space.
    Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
    Cc: Ian Abbott <abbotti@mev.co.uk>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    1f5cc359
kcomedilib_main.c 4.31 KB