Skip to content

Commit

Permalink
ACM gadget: fix endianness in notifications
Browse files Browse the repository at this point in the history
[ Upstream commit cdd7928 ]

The gadget code exports the bitfield for serial status changes
over the wire in its internal endianness. The fix is to convert
to little endian before sending it over the wire.

Signed-off-by: Oliver Neukum <[email protected]>
Tested-by: 家瑋 <[email protected]>
CC: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
oneukum authored and Sasha Levin committed May 17, 2017
1 parent 861b5c1 commit 09b3048
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/gadget/function/f_acm.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,15 @@ static int acm_notify_serial_state(struct f_acm *acm)
{
struct usb_composite_dev *cdev = acm->port.func.config->cdev;
int status;
__le16 serial_state;

spin_lock(&acm->lock);
if (acm->notify_req) {
dev_dbg(&cdev->gadget->dev, "acm ttyGS%d serial state %04x\n",
acm->port_num, acm->serial_state);
serial_state = cpu_to_le16(acm->serial_state);
status = acm_cdc_notify(acm, USB_CDC_NOTIFY_SERIAL_STATE,
0, &acm->serial_state, sizeof(acm->serial_state));
0, &serial_state, sizeof(acm->serial_state));
} else {
acm->pending = true;
status = 0;
Expand Down

0 comments on commit 09b3048

Please sign in to comment.