Skip to content

Commit ac780c2

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: iuu_phoenix: fix led-activity helpers
[ Upstream commit de37458 ] 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: 60a8fc0 ("USB: add iuu_phoenix driver") Reported-by: George Spelvin <lkml@sdf.org> Link: https://lore.kernel.org/r/20200716085056.31471-1-johan@kernel.org Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 58a42b4 commit ac780c2

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

drivers/usb/serial/iuu_phoenix.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,11 @@ static void iuu_led_activity_on(struct urb *urb)
353353
struct usb_serial_port *port = urb->context;
354354
int result;
355355
char *buf_ptr = port->write_urb->transfer_buffer;
356-
*buf_ptr++ = IUU_SET_LED;
356+
357357
if (xmas) {
358-
get_random_bytes(buf_ptr, 6);
359-
*(buf_ptr+7) = 1;
358+
buf_ptr[0] = IUU_SET_LED;
359+
get_random_bytes(buf_ptr + 1, 6);
360+
buf_ptr[7] = 1;
360361
} else {
361362
iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255);
362363
}
@@ -374,13 +375,14 @@ static void iuu_led_activity_off(struct urb *urb)
374375
struct usb_serial_port *port = urb->context;
375376
int result;
376377
char *buf_ptr = port->write_urb->transfer_buffer;
378+
377379
if (xmas) {
378380
iuu_rxcmd(urb);
379381
return;
380-
} else {
381-
*buf_ptr++ = IUU_SET_LED;
382-
iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
383382
}
383+
384+
iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
385+
384386
usb_fill_bulk_urb(port->write_urb, port->serial->dev,
385387
usb_sndbulkpipe(port->serial->dev,
386388
port->bulk_out_endpointAddress),

0 commit comments

Comments
 (0)