Skip to contentSkip to conversation

Return ENODEV instead of EINVAL when trying to open ACM device.

PATCH In review Thadeu Lima de Souza Cascardo 2 participants 4 messages Jun 24, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Return ENODEV instead of EINVAL when trying to open ACM device.

This is required, otherwise a user will get a EINVAL while opening a non-existing device, instead of ENODEV.

This is what I get with this patch applied now instead of an "Invalid argument".

cascardo@vespa:~$ cat /dev/ttyACM0
cat: /dev/ttyACM0: No such device
cascardo@vespa:~$
---
 drivers/usb/class/cdc-acm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/class/cdc-acm.c +1 -1
index 38bfdb0..02eb60b 100644
@@ -550,7 +550,7 @@ static void acm_waker(struct work_struct *waker)
 static int acm_tty_open(struct tty_struct *tty, struct file *filp)
 {
 	struct acm *acm;
-	int rv = -EINVAL;
+	int rv = -ENODEV;
 	int i;
 	dbg("Entering acm_tty_open.");
 
Signature · 1 line
1.6.3
#1 lore raw

PATCH 2/3 Fix oops when closing ACM tty device right after open has failed.

This commit 10077d4a6674f535abdbe25cdecb1202af7948f1 has stopped checking if there was a valid acm device associated to the tty, which is not true right after open fails and tty subsystem tries to close the device.

As an example, open fails with a non-existing device, when probe has never been called, because the device has never been plugged. This is common in systems with static modules and no udev.

---
 drivers/usb/class/cdc-acm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/class/cdc-acm.c +1 -1
index 02eb60b..3f10459 100644
@@ -677,7 +677,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
 
 	/* Perform the closing process and see if we need to do the hardware
 	   shutdown */
-	if (tty_port_close_start(&acm->port, tty, filp) == 0)
+	if (!acm || tty_port_close_start(&acm->port, tty, filp) == 0)
 		return;
 	acm_port_down(acm, 0);
 	tty_port_close_end(&acm->port, tty);
Signature · 1 line
1.6.3
#2 lore raw

PATCH 3/3 Fix oops when unexisting usb serial device is opened.

This commit 335f8514f200e63d689113d29cb7253a5c282967 has stopped properly checking if there is any usb serial associated with the tty in the close function. It happens the close function is called by releasing the terminal right after opening the device fails.

As an example, open fails with a non-existing device, when probe has never been called, because the device has never been plugged. This is common in systems with static modules and no udev.

---
 drivers/usb/serial/usb-serial.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/usb/serial/usb-serial.c +3 -0
index d595aa5..a842164 100644
@@ -333,6 +333,9 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
 {
 	struct usb_serial_port *port = tty->driver_data;
 
+	if (!port)
+		return;
+
 	dbg("%s - port %d", __func__, port->number);
 
 
Signature · 1 line
1.6.3
#3 lore raw

Re: [PATCH 2/3] Fix oops when closing ACM tty device right after open has failed.

In reply to Thadeu Lima de Souza Cascardo
Quoted 1 line · Thadeu Lima de Souza Cascardo

This commit 10077d4a6674f535abdbe25cdecb1202af7948f1 has stopped

You still have git ids in your patch body :)

don't worry, I can edit them out for these two, I'll go queue this up.

thanks,

greg k-h