Re: usb-serial.c question - potential Memory fault

<[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <002901c7d2a4$5211b470$f6351d50$@com>
No need to split.

This is just what I need :-)

Thanks a lot.

Alain

-----Message d'origine-----
De : Oliver Neukum [mailto:[email protected]] 
Envoyé : lundi 30 juillet 2007 14:18
À : [email protected]
Cc : [email protected]
Objet : Re: [linux-usb-devel] usb-serial.c question - potential Memory fault

Am Montag 30 Juli 2007 schrieb [email protected]:
> This is quite dangerous :-)
> 
> You can't apply a user requested buffer_size to interrupt_buffer !
> 
> The API should only apply the buffer size to bulk buffers...

Right you are. What about this? Or do you need split sizes
for input and output?

	Regards
		Oliver
---

--- a/include/linux/usb/serial.h	2007-07-30 12:19:39.000000000 +0200
+++ b/include/linux/usb/serial.h	2007-07-30 12:19:46.000000000 +0200
@@ -201,6 +201,7 @@ static inline void usb_set_serial_data (
 struct usb_serial_driver {
 	const char *description;
 	const struct usb_device_id *id_table;
+	int	buffer_size;
 	char	num_interrupt_in;
 	char	num_interrupt_out;
 	char	num_bulk_in;
--- a/drivers/usb/serial/usb-serial.c	2007-07-30 12:20:11.000000000 +0200
+++ b/drivers/usb/serial/usb-serial.c	2007-07-30 12:20:15.000000000 +0200
@@ -866,7 +866,7 @@ int usb_serial_probe(struct usb_interfac
 			dev_err(&interface->dev, "No free urbs
available\n");
 			goto probe_error;
 		}
-		buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+		buffer_size = type->buffer_size ? type->buffer_size :
le16_to_cpu(endpoint->wMaxPacketSize);
 		port->bulk_in_size = buffer_size;
 		port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
 		port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
@@ -890,7 +890,7 @@ int usb_serial_probe(struct usb_interfac
 			dev_err(&interface->dev, "No free urbs
available\n");
 			goto probe_error;
 		}
-		buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+		buffer_size = type->buffer_size ? type->buffer_size :
le16_to_cpu(endpoint->wMaxPacketSize);
 		port->bulk_out_size = buffer_size;
 		port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
 		port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL);


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
[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.