From patchwork Wed Oct 12 06:01:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9372119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B866607FD for ; Wed, 12 Oct 2016 06:05:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E52C529B57 for ; Wed, 12 Oct 2016 06:05:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8C6629B60; Wed, 12 Oct 2016 06:05:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AB7429B57 for ; Wed, 12 Oct 2016 06:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752236AbcJLGFL (ORCPT ); Wed, 12 Oct 2016 02:05:11 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:23847 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752097AbcJLGFK (ORCPT ); Wed, 12 Oct 2016 02:05:10 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u9C63hg9030434 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Oct 2016 06:03:44 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u9C63hgs024597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Oct 2016 06:03:43 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u9C63gi3026928; Wed, 12 Oct 2016 06:03:43 GMT Received: from mwanda (/154.122.16.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Oct 2016 23:03:37 -0700 Date: Wed, 12 Oct 2016 09:01:59 +0300 From: Dan Carpenter To: Dan Williams , Andy Green Cc: Vinod Koul , dmaengine@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch 2/2] k3dma: tighten range checking a bit Message-ID: <20161012060158.GB12841@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP My static checker complains that it's possible for "num" to be negative. I haven't investigated this completely, but it's more natural to make the type unsigned and that makes the static checker happy. Signed-off-by: Dan Carpenter --- Hm... I probably should investigate this a bit more because the same code is copy and pasted all over the place. -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c index aabcb79..7c636c53 100644 --- a/drivers/dma/k3dma.c +++ b/drivers/dma/k3dma.c @@ -440,7 +440,7 @@ static void k3_dma_fill_desc(struct k3_dma_desc_sw *ds, dma_addr_t dst, ds->desc_hw[num].config = ccfg; } -static struct k3_dma_desc_sw *k3_dma_alloc_desc_resource(int num, +static struct k3_dma_desc_sw *k3_dma_alloc_desc_resource(size_t num, struct dma_chan *chan) { struct k3_dma_chan *c = to_k3_chan(chan); @@ -449,7 +449,7 @@ static struct k3_dma_desc_sw *k3_dma_alloc_desc_resource(int num, int lli_limit = LLI_BLOCK_SIZE / sizeof(struct k3_desc_hw); if (num > lli_limit) { - dev_dbg(chan->device->dev, "vch %p: sg num %d exceed max %d\n", + dev_dbg(chan->device->dev, "vch %p: sg num %lu exceed max %d\n", &c->vc, num, lli_limit); return NULL; } @@ -476,7 +476,7 @@ static struct dma_async_tx_descriptor *k3_dma_prep_memcpy( struct k3_dma_chan *c = to_k3_chan(chan); struct k3_dma_desc_sw *ds; size_t copy = 0; - int num = 0; + size_t num = 0; if (!len) return NULL;