Commit aea0d43b authored by Pete Zaitcev's avatar Pete Zaitcev Committed by Greg Kroah-Hartman

Staging: rspiusb: use NULL virtual address instead of a bogus one

The main problem here is that I just cannot see how this could ever
be correct:

	usb_fill_bulk_urb(pdx->PixelUrb[frameInfo][i], pdx->udev, epAddr,
		(dma_addr_t *) sg_dma_address(&pdx->sgl[frameInfo][i]),
 		sg_dma_len(&pdx->sgl[frameInfo][i]),

You cannot take a DMA address, cast it to a _pointer to_ a DMA address,
and then regard it as a virtual address of the transfer buffer.
However, finding the right virtual address was too hard for me,
so I just stubbed it with NULL. At least usbmon won't oops then
(it will not show any data but it's better than crashing).

Also, too big a buffer was allocated elsewhere.

And since we're at it, drop clearly unnecessary usb_buffer_alloc too,
leaving it where it may be useful.
Signed-off-by: default avatarPete Zaitcev <zaitcev@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f408adeb
...@@ -444,8 +444,7 @@ static void piusb_write_bulk_callback(struct urb *urb) ...@@ -444,8 +444,7 @@ static void piusb_write_bulk_callback(struct urb *urb)
__func__, status); __func__, status);
pdx->pendingWrite = 0; pdx->pendingWrite = 0;
usb_buffer_free(urb->dev, urb->transfer_buffer_length, kfree(urb->transfer_buffer);
urb->transfer_buffer, urb->transfer_dma);
} }
int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len, int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
...@@ -457,9 +456,7 @@ int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len, ...@@ -457,9 +456,7 @@ int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
urb = usb_alloc_urb(0, GFP_KERNEL); urb = usb_alloc_urb(0, GFP_KERNEL);
if (urb != NULL) { if (urb != NULL) {
kbuf = kbuf = kmalloc(len, GFP_KERNEL);
usb_buffer_alloc(pdx->udev, len, GFP_KERNEL,
&urb->transfer_dma);
if (!kbuf) { if (!kbuf) {
dev_err(&pdx->udev->dev, "buffer_alloc failed\n"); dev_err(&pdx->udev->dev, "buffer_alloc failed\n");
return -ENOMEM; return -ENOMEM;
...@@ -470,7 +467,6 @@ int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len, ...@@ -470,7 +467,6 @@ int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
} }
usb_fill_bulk_urb(urb, pdx->udev, pdx->hEP[io->endpoint], kbuf, usb_fill_bulk_urb(urb, pdx->udev, pdx->hEP[io->endpoint], kbuf,
len, piusb_write_bulk_callback, pdx); len, piusb_write_bulk_callback, pdx);
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
err = usb_submit_urb(urb, GFP_KERNEL); err = usb_submit_urb(urb, GFP_KERNEL);
if (err) { if (err) {
dev_err(&pdx->udev->dev, dev_err(&pdx->udev->dev,
...@@ -641,7 +637,7 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx) ...@@ -641,7 +637,7 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx)
numPagesRequired = numPagesRequired =
((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT; ((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT;
dbg("Number of pages needed = %d", numPagesRequired); dbg("Number of pages needed = %d", numPagesRequired);
maplist_p = vmalloc(numPagesRequired * sizeof(struct page)); maplist_p = vmalloc(numPagesRequired * sizeof(struct page *));
if (!maplist_p) { if (!maplist_p) {
dbg("Can't Allocate Memory for maplist_p"); dbg("Can't Allocate Memory for maplist_p");
return -ENOMEM; return -ENOMEM;
...@@ -712,9 +708,7 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx) ...@@ -712,9 +708,7 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx)
usb_fill_bulk_urb(pdx->PixelUrb[frameInfo][i], usb_fill_bulk_urb(pdx->PixelUrb[frameInfo][i],
pdx->udev, pdx->udev,
epAddr, epAddr,
(dma_addr_t *) sg_dma_address(&pdx-> NULL, // non-DMA HC? buy a better hardware
sgl[frameInfo]
[i]),
sg_dma_len(&pdx->sgl[frameInfo][i]), sg_dma_len(&pdx->sgl[frameInfo][i]),
piusb_readPIXEL_callback, (void *)pdx); piusb_readPIXEL_callback, (void *)pdx);
pdx->PixelUrb[frameInfo][i]->transfer_dma = pdx->PixelUrb[frameInfo][i]->transfer_dma =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment