Commit ac780c22 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: serial: iuu_phoenix: fix led-activity helpers

[ Upstream commit de37458f ]

The set-led command is eight bytes long and starts with a command byte
followed by six bytes of RGB data and ends with a byte encoding a
frequency (see iuu_led() and iuu_rgbf_fill_buffer()).

The led activity helpers had a few long-standing bugs which corrupted
the command packets by inserting a second command byte and thereby
offsetting the RGB data and dropping the frequency in non-xmas mode.

In xmas mode, a related off-by-one error left the frequency field
uninitialised.

Fixes: 60a8fc01 ("USB: add iuu_phoenix driver")
Reported-by: default avatarGeorge Spelvin <lkml@sdf.org>
Link: https://lore.kernel.org/r/20200716085056.31471-1-johan@kernel.orgReviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 58a42b44
...@@ -353,10 +353,11 @@ static void iuu_led_activity_on(struct urb *urb) ...@@ -353,10 +353,11 @@ static void iuu_led_activity_on(struct urb *urb)
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
int result; int result;
char *buf_ptr = port->write_urb->transfer_buffer; char *buf_ptr = port->write_urb->transfer_buffer;
*buf_ptr++ = IUU_SET_LED;
if (xmas) { if (xmas) {
get_random_bytes(buf_ptr, 6); buf_ptr[0] = IUU_SET_LED;
*(buf_ptr+7) = 1; get_random_bytes(buf_ptr + 1, 6);
buf_ptr[7] = 1;
} else { } else {
iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255); iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255);
} }
...@@ -374,13 +375,14 @@ static void iuu_led_activity_off(struct urb *urb) ...@@ -374,13 +375,14 @@ static void iuu_led_activity_off(struct urb *urb)
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
int result; int result;
char *buf_ptr = port->write_urb->transfer_buffer; char *buf_ptr = port->write_urb->transfer_buffer;
if (xmas) { if (xmas) {
iuu_rxcmd(urb); iuu_rxcmd(urb);
return; return;
} else {
*buf_ptr++ = IUU_SET_LED;
iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
} }
iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
usb_fill_bulk_urb(port->write_urb, port->serial->dev, usb_fill_bulk_urb(port->write_urb, port->serial->dev,
usb_sndbulkpipe(port->serial->dev, usb_sndbulkpipe(port->serial->dev,
port->bulk_out_endpointAddress), port->bulk_out_endpointAddress),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment