Skip to content

Commit 1be5e57

Browse files
committed
Clear USB fault when getting device ID (Issue #1606)
1 parent 2fb186a commit 1be5e57

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Changes in CUPS v2.4.20 (YYYY-MM-DD)
1111
mode.
1212
- Increased the size of the SNMP supply name buffer used by the network backends
1313
(Issue #1604)
14+
- The USB backend now clears a halt on USB errors (Issue #1606)
1415
- Fixed mapping of standard PPD/PWG/legacy media size names to the local PPD
1516
size name (Issue #1375)
1617
- Fixed handling of multiple PPD: keywords from filters (Issue #1562,

backend/usb-libusb.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* LIBUSB interface code for CUPS.
33
*
4-
* Copyright © 2020-2025 by OpenPrinting.
4+
* Copyright © 2020-2026 by OpenPrinting.
55
* Copyright © 2007-2019 by Apple Inc.
66
*
77
* Licensed under Apache License v2.0. See the file "LICENSE" for more
@@ -1075,16 +1075,15 @@ get_device_id(usb_printer_t *printer, /* I - Printer */
10751075
char *buffer, /* I - String buffer */
10761076
size_t bufsize) /* I - Number of bytes in buffer */
10771077
{
1078-
size_t length; /* Length of device ID */
1078+
int err; /* libusb error */
1079+
size_t length; /* Length of device ID */
10791080

10801081

1081-
if (libusb_control_transfer(printer->handle,
1082-
LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_ENDPOINT_IN |
1083-
LIBUSB_RECIPIENT_INTERFACE,
1084-
0, printer->conf,
1085-
(printer->iface << 8) | printer->altset,
1086-
(unsigned char *)buffer, bufsize, 5000) < 0)
1082+
if ((err = libusb_control_transfer(printer->handle, LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_ENDPOINT_IN | LIBUSB_RECIPIENT_INTERFACE, 0, printer->conf, (printer->iface << 8) | printer->altset, (unsigned char *)buffer, bufsize, 5000)) < 0)
10871083
{
1084+
if (err == LIBUSB_ERROR_PIPE)
1085+
libusb_clear_halt(printer->handle, printer->read_endp);
1086+
10881087
*buffer = '\0';
10891088
return (-1);
10901089
}

0 commit comments

Comments
 (0)