From patchwork Mon Jan 5 08:23:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asaf Vertz X-Patchwork-Id: 5565451 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 26C779F4DC for ; Mon, 5 Jan 2015 08:31:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3EEA22015A for ; Mon, 5 Jan 2015 08:31:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77D4320145 for ; Mon, 5 Jan 2015 08:31:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753183AbbAEIbc (ORCPT ); Mon, 5 Jan 2015 03:31:32 -0500 Received: from mail-wi0-f176.google.com ([209.85.212.176]:39283 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751628AbbAEIbb (ORCPT ); Mon, 5 Jan 2015 03:31:31 -0500 Received: by mail-wi0-f176.google.com with SMTP id ex7so2759161wid.9 for ; Mon, 05 Jan 2015 00:31:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=ZxB644l4HNwdnsd3tJuQhlmXsHKIL7tIqF8jEt72Q4s=; b=bvq3q41VnJYQsW+/QYX91mdkhI+1iei4xO7QYYpfJj8i6tMLzd4vSuzEVhxOhlqygC I/7ZcR0lywTXSUhTnH1ujRSNWZG/Wy65nTAJbJkkEfQEmDe4OACy8PCx6fjUonek0C84 1RAPbEs2CDQBLBVp1mE2f+xa4wwxCRb0bai8c9YUi/fojJIIk97kFc536/HgPGMQGYHV owsMrs8KO04SuTj3ZRV9hMx+2vv+ILJwaxv1mVT43Txof/JEh3N/P3qtz810CxrqzKgt LmMHwAtFmNp3hZq6/RxlzwGnaRYOyVhoXwyBU73AUKISrU6E4SBwoddCndv54dAIEDg+ Xk2g== X-Gm-Message-State: ALoCoQmigRtXH1hyR0DQWXy26RzEph+fGLKnqtiSdKjI1lTfWxhmnhCgI/7WShJBLhvz38av7+hi X-Received: by 10.194.93.5 with SMTP id cq5mr169880078wjb.84.1420446193564; Mon, 05 Jan 2015 00:23:13 -0800 (PST) Received: from localhost ([62.219.160.253]) by mx.google.com with ESMTPSA id hl1sm48566952wjc.18.2015.01.05.00.23.12 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 05 Jan 2015 00:23:12 -0800 (PST) Date: Mon, 5 Jan 2015 10:23:10 +0200 From: Asaf Vertz To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto: omap-des: fix BUG_ON condition Message-ID: <20150105082310.GA19423@ubuntu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dd->total is unsigned so it won't do any good to check for negative value after subtracting instead of that we should check if the subtracted value is bigger than him This was partially found by using a static code analysis program called cppcheck. Signed-off-by: Asaf Vertz --- drivers/crypto/omap-des.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index e350f5b..0b8dcf5 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -965,9 +965,9 @@ static irqreturn_t omap_des_irq(int irq, void *dev_id) } } - dd->total -= DES_BLOCK_SIZE; + BUG_ON(dd->total < DES_BLOCK_SIZE); - BUG_ON(dd->total < 0); + dd->total -= DES_BLOCK_SIZE; /* Clear IRQ status */ status &= ~DES_REG_IRQ_DATA_OUT;