Re: patch usb-add-urb_free_buffer-flag-and-the-logic-behind-it.patch added to gregkh-2.6 tree

Pete Zaitcev <[email protected]>
Newsgroups gmane.linux.usb.devel
Organization Red Hat, Inc.
Message-ID <[email protected]>
On Mon, 25 Jun 2007 01:08:23 -0700, <[email protected]> wrote:

>      usb-add-urb_free_buffer-flag-and-the-logic-behind-it.patch

> +++ b/drivers/usb/core/urb.c
> @@ -13,6 +13,9 @@ static void urb_destroy(struct kref *kre
>  {
>  	struct urb *urb = to_urb(kref);
>  
> +	if (urb->transfer_flags & URB_FREE_BUFFER)
> +		kfree(urb->transfer_buffer);
> +
>  	kfree(urb);

I liked the constructors which kept the URB_FREE_BUFFER outside of grabby
little hands of drivers, but this is good too, I suppose. I'm going to
use this right away. Marcel, please let me know if I'm doing it wrong.

-- Pete

--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -330,9 +330,6 @@ static void usblp_bulk_write(struct urb *urb)
 	wake_up(&usblp->wwait);
 	spin_unlock(&usblp->lock);
 
-	/* XXX Use usb_setup_bulk_urb when available. Talk to Marcel. */
-	kfree(urb->transfer_buffer);
-	urb->transfer_buffer = NULL;	/* Not refcounted, so to be safe... */
 	usb_free_urb(urb);
 }
 
@@ -718,6 +715,7 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
 			usb_sndbulkpipe(usblp->dev,
 			  usblp->protocol[usblp->current_protocol].epwrite->bEndpointAddress),
 			writebuf, transfer_length, usblp_bulk_write, usblp);
+		writeurb->transfer_flags |= URB_FREE_BUFFER;
 		usb_anchor_urb(writeurb, &usblp->urbs);
 
 		if (copy_from_user(writebuf, 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.