From patchwork Tue May 6 15:44:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 4122511 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 429299F1E1 for ; Tue, 6 May 2014 15:44:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B576201ED for ; Tue, 6 May 2014 15:44:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 008D52022A for ; Tue, 6 May 2014 15:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755270AbaEFPos (ORCPT ); Tue, 6 May 2014 11:44:48 -0400 Received: from top.free-electrons.com ([176.31.233.9]:52539 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755237AbaEFPor (ORCPT ); Tue, 6 May 2014 11:44:47 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id E54CE1242; Tue, 6 May 2014 17:44:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from localhost (128-79-216-6.hfc.dyn.abo.bbox.fr [128.79.216.6]) by mail.free-electrons.com (Postfix) with ESMTPSA id 9B4A7123F; Tue, 6 May 2014 17:44:45 +0200 (CEST) From: Alexandre Belloni To: Mark Brown Cc: Nicolas Ferre , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Alexandre Belloni Subject: [PATCH] spi: atmel: fix incorrect comparison Date: Tue, 6 May 2014 17:44:41 +0200 Message-Id: <1399391081-16095-1-git-send-email-alexandre.belloni@free-electrons.com> X-Mailer: git-send-email 1.9.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Found using smatch: drivers/spi/spi-atmel.c:878 atmel_spi_pump_pio_data() warn: unsigned 'as->current_remaining_bytes' is never less than zero. Signed-off-by: Alexandre Belloni Acked-by: Nicolas Ferre --- drivers/spi/spi-atmel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 079e6b1b0cdb..39417fd8462f 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -874,8 +874,9 @@ atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer) spi_readl(as, RDR); } if (xfer->bits_per_word > 8) { - as->current_remaining_bytes -= 2; - if (as->current_remaining_bytes < 0) + if (as->current_remaining_bytes > 2) + as->current_remaining_bytes -= 2; + else as->current_remaining_bytes = 0; } else { as->current_remaining_bytes--;