From patchwork Fri Jun 3 00:48:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 69210 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp16385qgf; Thu, 2 Jun 2016 17:48:35 -0700 (PDT) X-Received: by 10.98.10.25 with SMTP id s25mr2060744pfi.124.1464914915483; Thu, 02 Jun 2016 17:48:35 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b22si3675402pfc.170.2016.06.02.17.48.35; Thu, 02 Jun 2016 17:48:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751654AbcFCAse (ORCPT + 2 others); Thu, 2 Jun 2016 20:48:34 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:36223 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbcFCAsc (ORCPT ); Thu, 2 Jun 2016 20:48:32 -0400 Received: by mail-pf0-f179.google.com with SMTP id f144so37463899pfa.3 for ; Thu, 02 Jun 2016 17:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=38ds220t6yM0w7E4fLP+HvLpURAbiXgi79O71VjAPuo=; b=VG7ONYhdO3lw+c8mQ5c0QNgDegQ27+TlGuQgl9SOT1NKPIjvGL/2ZW93W2L0PLjEvI fCzg2f/pd/USo+OqO4eYa5w3nzyQ7PqwZHoQ5caYg0KNETw39lL0MG4TRkf+YaAeaY6Z G26+mlHuvWVFuX+BTYflN6dKaINawR5VEPjS0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=38ds220t6yM0w7E4fLP+HvLpURAbiXgi79O71VjAPuo=; b=JCKLaNxbc9qnVVjpN0GYzpGq74LVdtnb/Z4jVP2FtgYhjVKRabhqRhpio8t3STUGw5 y5MhHUKT1ULSpHSNXeQBgyLjWwf6F1BDj4yEs0/NRggAnb4M4tMvQ0WSg8G9jgtOunL4 tcaUo0mmGPSMWMq9Tz2mmQwaCuIMORkyXugtOMH+mf9VLk6NNNHLTCML9g5U10K/Fb/e qTIe982lG4fygkn/lTWwgz4GFHXdpfKs2JjelybKNyKSZte/rFD71TL96Vnrdx+VCrSp pttyteuKemk6u33cSldOdbEKb/HlTPkBVGwJzlwyXOiz2+cyfZBK9YPOHOmD63Cp8+1W K3dg== X-Gm-Message-State: ALyK8tItJQuHXwrhFAN5UrIgk6YJXr4waJsVTGC/G2ZG6FYvDSBRVzLJMPil0HsIgmjUM/AH X-Received: by 10.98.67.138 with SMTP id l10mr1990735pfi.59.1464914911536; Thu, 02 Jun 2016 17:48:31 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id v184sm3509621pfb.24.2016.06.02.17.48.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Jun 2016 17:48:30 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , David Brown , Greg Kroah-Hartman , Jiri Slaby Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Rowand , Nicolas Dechesne , Ivan Ivanov , Stephen Boyd , stable@vger.kernel.org Subject: [PATCH] tty: serial: msm: Don't read off end of tx fifo Date: Thu, 2 Jun 2016 17:48:28 -0700 Message-Id: <1464914908-19059-1-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org For dm uarts in pio mode tx data is transferred to the fifo register 4 bytes at a time, but care is not taken when these 4 bytes spans the end of the xmit buffer so the loop might read up to 3 bytes past the buffer and then skip the actual data at the beginning of the buffer. Fix this by, analogous to the DMA case, make sure the chunk doesn't wrap the xmit buffer. Fixes: 3a878c430fd6 ("tty: serial: msm: Add TX DMA support") Cc: Andy Gross Cc: Ivan Ivanov Cc: Stephen Boyd Cc: stable@vger.kernel.org Reported-by: Frank Rowand Reported-by: Nicolas Dechesne Signed-off-by: Bjorn Andersson --- drivers/tty/serial/msm_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Andy Gross diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index b7d80bd57db9..7d62610d9de5 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -726,7 +726,7 @@ static void msm_handle_tx(struct uart_port *port) return; } - pio_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE); + pio_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); dma_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); dma_min = 1; /* Always DMA */