Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2656230pxa; Mon, 17 Aug 2020 15:41:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBaQdm4HV8JXd0fARtfDqz4IS+DjhBSpeXMnr1IsHIJjcD9jl8ofqH1smEZVQ9hbUf/Zim X-Received: by 2002:a17:906:a0c5:: with SMTP id bh5mr16900646ejb.120.1597704064471; Mon, 17 Aug 2020 15:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704064; cv=none; d=google.com; s=arc-20160816; b=rwBGnxDUFB5KCkkFP24qRjDKcotocN12nw5TEnimKzdGHvl8vv4gl3mys1aVaVVB+H wno4prdroZmJ6hB1cnFcMVzLVTk++Dk1u2F/B72V3AZx2boMzVfvGypdhpO7UIs1oHTa xnqcRrtWgldQOyonapEzUvLoxD6ZkyxnjPLirCxkK4B6Bwtps8GTw7+0Z68KuUnn/hYO ou7upsP5GMwYrUwYvERa9oawlF/Y6wQgbp7qwdQdHiS6BEdNJ89Gc/IU7azeBWPa66DA asv48UIe4y8zvNk3FDHnQ/dPQsgYQ+qON/Izrzwabqp9fQtPuNUMsRQ5bIBiCZUznkIE OQtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B+g2snowc3vsiuc2cUoQ5YF4jdqNm5gEWsyrMEZHpCw=; b=fYEF6MkGC41hfabM2M1NgVLekTaMrxcXzco3LIyF3zU5XUvkVxGgRZn3g/pIz5H5OT +PHLjr2eXLOy6W6BLOl77kui1PQpODvoXjB4SOyYSqHMUATAni1nZcfx6FaVdDohTk+V psUTlcZo0dSuSlgMuBloieC6DMPVqrKyR0uTvbqCoi6o2+S9igaRbv20xn+zyvpjJ/pE C43BgYG560+tOjYP+FJ0sXZRkwPX69PwrzZwIkUpxeYGPr+fyNurv0aMUZh3uHUwZ7Iv Sv5OvlGev53DDCUGU30b33eCeNd+phE56Ioy0Itx8wrC8NaiyZRtJZ3cSQTClBGAC3VG 1dQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1pisfiNd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pk23si11685003ejb.488.2020.08.17.15.40.41; Mon, 17 Aug 2020 15:41:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1pisfiNd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390684AbgHQSPi (ORCPT + 99 others); Mon, 17 Aug 2020 14:15:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:53934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388392AbgHQQGC (ORCPT ); Mon, 17 Aug 2020 12:06:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D38D820888; Mon, 17 Aug 2020 16:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680361; bh=a7E2beN0GPmKTpYoQDTwY7mJKGFsxlXkNeufTEdGSfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1pisfiNdwFp0CKI/BCwPzS4TUuftwZlJFhN+kfOz2k9AqsSVNSo1Eivdplbd6PGK3 65a3CpuaZlMM4eW7uzRyO25mYslMTU+4yNFWKYQrY0L8SHW8lne9h6nnDnvoLxB1oP 9h/VSrDije1E68kMit1kzSVy1QsliLg9eKWHjYDk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, George Spelvin , Johan Hovold , Sasha Levin Subject: [PATCH 5.4 155/270] USB: serial: iuu_phoenix: fix led-activity helpers Date: Mon, 17 Aug 2020 17:15:56 +0200 Message-Id: <20200817143803.548988411@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold [ Upstream commit de37458f8c2bfc465500a1dd0d15dbe96d2a698c ] 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: 60a8fc017103 ("USB: add iuu_phoenix driver") Reported-by: George Spelvin Link: https://lore.kernel.org/r/20200716085056.31471-1-johan@kernel.org Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold Signed-off-by: Sasha Levin --- drivers/usb/serial/iuu_phoenix.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index b8dfeb4fb2ed6..ffbb2a8901b2b 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -353,10 +353,11 @@ static void iuu_led_activity_on(struct urb *urb) struct usb_serial_port *port = urb->context; int result; char *buf_ptr = port->write_urb->transfer_buffer; - *buf_ptr++ = IUU_SET_LED; + if (xmas) { - get_random_bytes(buf_ptr, 6); - *(buf_ptr+7) = 1; + buf_ptr[0] = IUU_SET_LED; + get_random_bytes(buf_ptr + 1, 6); + buf_ptr[7] = 1; } else { 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) struct usb_serial_port *port = urb->context; int result; char *buf_ptr = port->write_urb->transfer_buffer; + if (xmas) { iuu_rxcmd(urb); 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_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), -- 2.25.1