drivers/usb/misc/iowarrior.c: NULL dereference
The Coverity checker spotted the following NULL dereference:
<-- snip -->
...
static ssize_t iowarrior_write(struct file *file,
const char __user *user_buffer, size_t count, loff_t *ppos)
{
...
if (!int_out_urb) {
retval = -ENOMEM;
dbg("%s Unable to allocate urb ", __func__);
goto error;
...
error:
usb_buffer_free(dev->udev, dev->report_size, buf,
int_out_urb->transfer_dma);... ^^^^^^^^^^^^^^^^^^^^^^^^^
<-- snip -->
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedAm Montag, 19. März 2007 10:25 schrieb Adrian Bunk:
Quoted 13 lines
static
ssize_tiowarrior_write(struct file *file,
const char__user*user_buffer,size_tcount,loff_t*ppos)
{
...if (!int_out_urb) { retval = -ENOMEM; dbg("%s Unable to allocate urb ", __func__); goto error; ... error: usb_buffer_free(dev->udev, dev->report_size, buf, int_out_urb->transfer_dma);
Quoted 1 line
... ^^^^^^^^^^^^^^^^^^^^^^^^^
Yes, that's a bug. The fix is compiling.
Regards
Oliver
Am Montag, 19. März 2007 10:25 schrieb Adrian Bunk:
Quoted 1 line
The Coverity checker spotted the following NULL dereference:
And this fixes an oops upon allocation failures.
Regards
Oliver
-----
drivers/usb/misc/iowarrior.c renamed from drivers/usb/misc/iowarrior.c.alt +4 -2
@@ -417,14 +417,14 @@if (!int_out_urb) { retval = -ENOMEM ;dbg ("%s Unable to allocate urb " , __func__); - goto error; + goto error_no_urb; } buf =usb_buffer_alloc (dev->udev, dev->report_size,GFP_KERNEL , &int_out_urb->transfer_dma);if (!buf) { retval = -ENOMEM ;dbg ("%s Unable to allocate buffer " , __func__); - goto error; + goto error_no_buffer; } usb_fill_int_urb(int_out_urb, dev->udev, usb_sndintpipe(dev->udev,
@@ -459,7 +459,9 @@ error:usb_buffer_free (dev->udev, dev->report_size, buf, int_out_urb->transfer_dma); +error_no_buffer:usb_free_urb (int_out_urb); +error_no_urb:atomic_dec (&dev->write_busy);wake_up_interruptible (&dev->write_wait); exit: