Re: [PATCH 48/50] staging: comedi: fix sparse warning in do_devconfig_ioctl()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012-09-19 18:27, H Hartley Sweeten wrote:
On Tuesday, September 18, 2012 11:47 AM, Ian Abbott wrote:
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@xxxxxxxxx>
---
  drivers/staging/comedi/comedi_fops.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 7d18325..55722b3 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -370,7 +370,8 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
  			return -ENOMEM;

  		if (copy_from_user(aux_data,
-				   comedi_aux_data(it.options, 0), aux_len)) {
+				   (unsigned char __user *
+				    )comedi_aux_data(it.options, 0), aux_len)) {
  			vfree(aux_data);
  			return -EFAULT;
  		}

Ian,

If we "fix" the drivers that still use this, couldn't the "aux_data" usage
be deprecated? Then we could just remove the comedi_aux_data()
function as well as the related chunk in do_devconfig_ioctl().

Yes, as long as we don't plan to support firmware loading for devices that don't support the auto-configuration mechanism.

The comedi_nonfree_firmware tarball has firmware for 5 drivers:

These two are good:
daqboard2000 - uses request_firmware() and attach_pci
ni_pcidio - uses request_firmware() and attach_pci

This one needs converted to attach_pci (this driver is a mess):
jr3_pci - uses request_firmware() still uses attach

This one is broken and needs fixed:
me4000 - uses attach_pci, the firmware upload code is missing

This one needs converted to request_firmware() and attach_pci
me_daq - uses comedi_aux_data() still uses attach

The usbdux, usbduxfast, and usbduxsigma drivers all use
request_firmware_nowait() in the usb_driver probe. The
comedi_driver for all these have both an attach and attach_usb.
The attach functions use comedi_aux_data(), the attach_pci
functions are triggered by the completion function of
request_firmware_nowait(). It looks like these could be fixed
by just dropping the attach method. BTW, where are the
firmware files for these drivers?

Yes, the attach method can be dropped for usbdux*. The firmware for those is in the linux-firmware package and git repository.

git://git.kernel.org/pub/scm/linux/kernel/git/dwmw2/linux-firmware.git

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux