Hello all,

Linux duran 2.4.18 #6 SMP Sun Jun 2 02:29:13 IDT 2002 i686 unknown

I experienced a memory leak due one shot interrupt transfer. I search the 
web and find that there is
http://www.kernel.org/pub/linux/kernel/people/gregkh/usb/2.4/usb-usb-uhci-2.4.18-pre6.patch
 
that should
fix this leak. So i downloaded 2.4.18 kernel and seems to me that there is 
still leak here ( i tested
same code with uhci and there is no leak)
I'm doing something wrong or leak still here ?
Below test code and explanation.

In usb-uhci  i added few line to count td_allocation
and print them out on unload.
and i have a leak in every urb transfer.
The td allocated in  (line 1472 ) never get freed. 22

_static int uhci_submit_int_urb (urb_t *urb)
....
if (alloc_td (s, &td, UHCI_PTR_DEPTH))   1472
                return -ENOMEM;
....

My driver code  (modified skeleton sample) :


static void skel_write_bulk_callback (struct urb *urb)
{
        struct usb_skel *dev = (struct usb_skel *)urb->context;
        printk(__FUNCTION__ " - minor %d\n", dev->minor);
        wake_up(&dev->irq_wait);
        return;
}

static int test_read(struct usb_skel *dev)
{
        int retval = 0;
        struct urb *urb = NULL;
        char *data = NULL;

        /* lock this object */
        down (&dev->sem);

        /* verify that the device wasn't unplugged */
        if (dev->udev == NULL) {
                retval = -ENODEV;
                goto exit;
        }
        urb = usb_alloc_urb(0);
        if (!urb)
        {
            retval = -ENOMEM;
            goto exit;
        }
        

        data = kmalloc(dev->int_pipe_size, GFP_DMA);
        
        if (!data)
        {
            retval = -ENOMEM;
            goto exit;
        }
        
        FILL_INT_URB(urb, dev->udev, dev->int_end_point, data ,
            dev->int_pipe_size, skel_write_bulk_callback, dev, 0);

         retval = usb_submit_urb(urb);

        if (retval)
            goto exit;

        interruptible_sleep_on(&dev->irq_wait);
exit:
        if (urb)
            usb_free_urb(urb);
        if (data)
           kfree(data);
        /* unlock the device */
        up (&dev->sem);

        return retval;
}


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to