Skip to content

Commit 323ece5

Browse files
Oliver Neukumgregkh
authored andcommitted
cdc-wdm: fix endianness bug in debug statements
Values directly from descriptors given in debug statements must be converted to native endianness. Signed-off-by: Oliver Neukum <oneukum@suse.de> CC: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 28965e1 commit 323ece5

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

drivers/usb/class/cdc-wdm.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static void wdm_int_callback(struct urb *urb)
245245
case USB_CDC_NOTIFY_RESPONSE_AVAILABLE:
246246
dev_dbg(&desc->intf->dev,
247247
"NOTIFY_RESPONSE_AVAILABLE received: index %d len %d",
248-
dr->wIndex, dr->wLength);
248+
le16_to_cpu(dr->wIndex), le16_to_cpu(dr->wLength));
249249
break;
250250

251251
case USB_CDC_NOTIFY_NETWORK_CONNECTION:
@@ -262,7 +262,9 @@ static void wdm_int_callback(struct urb *urb)
262262
clear_bit(WDM_POLL_RUNNING, &desc->flags);
263263
dev_err(&desc->intf->dev,
264264
"unknown notification %d received: index %d len %d\n",
265-
dr->bNotificationType, dr->wIndex, dr->wLength);
265+
dr->bNotificationType,
266+
le16_to_cpu(dr->wIndex),
267+
le16_to_cpu(dr->wLength));
266268
goto exit;
267269
}
268270

@@ -402,7 +404,7 @@ static ssize_t wdm_write
402404
USB_RECIP_INTERFACE);
403405
req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND;
404406
req->wValue = 0;
405-
req->wIndex = desc->inum;
407+
req->wIndex = desc->inum; /* already converted */
406408
req->wLength = cpu_to_le16(count);
407409
set_bit(WDM_IN_USE, &desc->flags);
408410
desc->outbuf = buf;
@@ -416,7 +418,7 @@ static ssize_t wdm_write
416418
goto out_free_mem_pm;
417419
} else {
418420
dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d",
419-
req->wIndex);
421+
le16_to_cpu(req->wIndex));
420422
}
421423

422424
usb_autopm_put_interface(desc->intf);
@@ -821,7 +823,7 @@ static int wdm_create(struct usb_interface *intf, struct usb_endpoint_descriptor
821823
desc->irq->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
822824
desc->irq->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE;
823825
desc->irq->wValue = 0;
824-
desc->irq->wIndex = desc->inum;
826+
desc->irq->wIndex = desc->inum; /* already converted */
825827
desc->irq->wLength = cpu_to_le16(desc->wMaxCommand);
826828

827829
usb_fill_control_urb(

0 commit comments

Comments
 (0)