Skip to contentSkip to conversation

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

PATCH In review Thadeu Lima de Souza Cascardo 3 participants 10 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.

---
 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.

---
 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.

---
 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 3/3] Fix oops when unexisting usb serial device is opened.

Quoted 4 lines · Thadeu Lima de Souza Cascardo

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.

Why would open fail?

thanks,

greg k-h

#4 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

Please don't reference git commit ids that are not in Linus's tree, as it doesn't make any sense to anyone.

Quoted 3 lines

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.

Why would open fail?

thanks,

greg k-h

#5 lore raw

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

Quoted 6 lines · Greg KH
Quoted 1 line · Thadeu Lima de Souza Cascardo

This commit 10077d4a6674f535abdbe25cdecb1202af7948f1 has stopped

Please don't reference git commit ids that are not in Linus's tree, as it doesn't make any sense to anyone.

It is in Linus's tree. git log torvalds/master..10077d4 gives me nothing.

cascardo@vespa:~/linux$ git remote show torvalds
* remote torvalds
  URL:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/
Quoted 6 lines
Quoted 3 lines

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.

Why would open fail?

Explained in a second version submitted already, but basically because there's no such device.

Quoted 3 lines

thanks,

greg k-h

#6 lore raw

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

Quoted 10 lines · Thadeu Lima de Souza Cascardo
Quoted 6 lines · Greg KH
Quoted 1 line · Thadeu Lima de Souza Cascardo

This commit 10077d4a6674f535abdbe25cdecb1202af7948f1 has stopped

Please don't reference git commit ids that are not in Linus's tree, as it doesn't make any sense to anyone.

It is in Linus's tree. git log torvalds/master..10077d4 gives me nothing.

Oh, ok, your phrase was a bit confusing.

It should say:
The commit XXXXX has stopped...

thanks,

greg k-h

#7 lore raw
In reply to Thadeu Lima de Souza Cascardo
Quoted 10 lines · Thadeu Lima de Souza Cascardo
---
 drivers/usb/class/cdc-acm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/class/cdc-acm.c +0 -0
index 38bfdb0..02eb60b 100644

drivers/usb/class/cdc-acm.c static void acm_waker(struct work_struct *waker) · line 553

Quoted 5 lines
drivers/usb/class/cdc-acm.c +1 -1
@@ -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;

Why is this needed?

thanks,

greg k-h

Acked-by
#8 lore raw

Am Mittwoch, 24. Juni 2009 22:40:15 schrieb Greg KH:

Quoted 6 lines · Thadeu Lima de Souza Cascardo
Quoted 5 lines
---
 drivers/usb/class/cdc-acm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 12 lines

drivers/usb/class/cdc-acm.c static void acm_waker(struct work_struct *waker) · line 553

Quoted 10 lines
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;

Why is this needed?

The current error return is incorrect. If the table entry is gone, the device has been disconnected, hence -ENODEV.

Regards
Oliver

#9 lore raw
Quoted 20 lines · Oliver Neukum

Am Mittwoch, 24. Juni 2009 22:40:15 schrieb Greg KH:

Quoted 6 lines · Thadeu Lima de Souza Cascardo
Quoted 5 lines
---
 drivers/usb/class/cdc-acm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 12 lines

drivers/usb/class/cdc-acm.c static void acm_waker(struct work_struct *waker) · line 553

Quoted 10 lines
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;

Why is this needed?

Quoted 7 lines

The current error return is incorrect. If the table entry is gone, the device has been disconnected, hence -ENODEV.

Regards
Oliver

Or if the device has never been connected at all.