Skip to contentSkip to conversation

usb: cdc-acm: handle unlinked urb in acm read callback

PATCH Superseded Lu Baolu 2 participants 3 messages Dec 30, 2015

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Lu Baolu

author
#0 lore raw

PATCH v2 1/1 usb: cdc-acm: handle unlinked urb in acm read callback

In current acm driver, the bulk-in callback function ignores the URBs unlinked in usb core.

This causes unexpected data loss in some cases. For example, runtime suspend entry will unlinked all urbs and set urb->status to -ENOENT even those urbs might have data not processed yet. Hence, data loss occurs.

This patch lets bulk-in callback function handle unlinked urbs to avoid data loss.

---
 drivers/usb/class/cdc-acm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-acm.c +2 -1
index 26ca4f9..8cd193b 100644
@@ -428,7 +428,8 @@ static void acm_read_bulk_callback(struct urb *urb)
 		set_bit(rb->index, &acm->read_urbs_free);
 		dev_dbg(&acm->data->dev, "%s - non-zero urb status: %d\n",
 							__func__, status);
-		return;
+		if ((status != -ENOENT) || (urb->actual_length == 0))
+			return;
 	}
 
 	usb_mark_last_busy(acm->dev);
Signature · 1 line
2.1.4
#1 lore raw
Quoted 11 lines · Lu Baolu

In current acm driver, the bulk-in callback function ignores the URBs unlinked in usb core.

This causes unexpected data loss in some cases. For example, runtime suspend entry will unlinked all urbs and set urb->status to -ENOENT even those urbs might have data not processed yet. Hence, data loss occurs.

This patch lets bulk-in callback function handle unlinked urbs to avoid data loss.

Quoted 7 lines
---
 drivers/usb/class/cdc-acm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

What changed in v2?

Please always document that below the --- line.

author
#2 lore raw
Quoted 19 lines · Greg Kroah-Hartman
Quoted 11 lines · Lu Baolu

In current acm driver, the bulk-in callback function ignores the URBs unlinked in usb core.

This causes unexpected data loss in some cases. For example, runtime suspend entry will unlinked all urbs and set urb->status to -ENOENT even those urbs might have data not processed yet. Hence, data loss occurs.

This patch lets bulk-in callback function handle unlinked urbs to avoid data loss.

Quoted 7 lines
---
 drivers/usb/class/cdc-acm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 3 lines

What changed in v2?

Please always document that below the --- line.

Thank you for the reminding.

I will send a new version of patch with change logs.

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html