Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp590303iog; Mon, 13 Jun 2022 08:43:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWAP1OfQlmi74ueVJ+qUaWc6bqr12eURg6XZB3HAmC8RFPB8K1io4yAH5HT8BTQ9HrxVXw X-Received: by 2002:a17:906:7a5e:b0:6fe:d93d:21a3 with SMTP id i30-20020a1709067a5e00b006fed93d21a3mr413753ejo.596.1655134988527; Mon, 13 Jun 2022 08:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134988; cv=none; d=google.com; s=arc-20160816; b=ftD3y61La++mCbN46qU7jaTzqdBy4KQQzz9u3ymukPTEhJdrVSxLQcqjMsB+T0BJVq +FGrg101hPGpINBnNA+wdj36GrClqeNfNaWa2HgzFjN2BuwVtX8oekO07MML3xjT3M1b usFrlMp4+vM+hyf9+lFgx4j6FxEW6o6fZN9toYk9FjJx9/TXQhRrhl1T3McWYFeMagZ3 +BYmCXtAL7xD3BI28GvJ1d/KiBOyDJLDj6U4R36xGk8Dvh58wJ1v3qvkX1TiS85BAlqr 5JDc2+BO8vNrKneocyJFZXbOHNu8SgF2lx4A96FiLCFFW71ZIj92BsBBtZheBlIszhPt lc1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KI3Fappda7QRZjY+FSXPacTy8KrMyNLpSrzqPH4dvfw=; b=H7NWud54Z3RFVGX8/vZkRw1tM9mNjjSzZ1Ytx/5LYrCL9cj20+4rUhDE6MGFoDVBWG HvrxWquqQSqxAihUae1HQpx3PTWLN9IBKrGTTBFog+BzyOEGBvtfgN3iAI8wTtZWt5el 26I3TUt1WmNhqwuSD6TVQUPaebTNJaqR/uo0R5IRNsrXFtF81xRfPIajpsg1H50j6h2X EEoK2h3FNbOeAORBjgcZYoyg5gW0By9LwFmSa/DMqtsi0AjWy+wABk8O19sa7b3hbezb 60h5ErdzdkhaJQw1kf3xm62BJshKzJef1XYLMHZvJLIioijCvhE2HXyPEJ1IGGEtczQP tSwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M2g0Ebul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j30-20020a170906535e00b00715785bb696si6056062ejo.447.2022.06.13.08.42.40; Mon, 13 Jun 2022 08:43:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M2g0Ebul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356563AbiFMLor (ORCPT + 99 others); Mon, 13 Jun 2022 07:44:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355489AbiFMLjB (ORCPT ); Mon, 13 Jun 2022 07:39:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E48C52C10F; Mon, 13 Jun 2022 03:48:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9D37AB80D3C; Mon, 13 Jun 2022 10:48:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0902EC34114; Mon, 13 Jun 2022 10:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117317; bh=zHWqe6zjLUR4kWXXfBNVDYv3427Js0IldgUO8MhfWOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M2g0EbulqEdE4Hx2h75G412+cmbzx9mejT5puH+0JtG5r5Kkgnl7Z4QjuIwRhpzl6 iRU7pAnuTbDsB1vIW9g5HakcEsM+k0iW9vdTwpSrd6ByKSU4/y68b0nGDIY85uRyPm Zn4Na6pkq5M6gO4xCUG8hmLRUAAx6lAeGG+aUCC8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Radhey Shyam Pandey , Vinod Koul , Sasha Levin Subject: [PATCH 5.4 344/411] dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data type Date: Mon, 13 Jun 2022 12:10:17 +0200 Message-Id: <20220613094939.024289363@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Radhey Shyam Pandey [ Upstream commit f9a9f43a62a04ec3183fb0da9226c7706eed0115 ] In zynqmp_dma_alloc/free_chan_resources functions there is a potential overflow in the below expressions. dma_alloc_coherent(chan->dev, (2 * chan->desc_size * ZYNQMP_DMA_NUM_DESCS), &chan->desc_pool_p, GFP_KERNEL); dma_free_coherent(chan->dev,(2 * ZYNQMP_DMA_DESC_SIZE(chan) * ZYNQMP_DMA_NUM_DESCS), chan->desc_pool_v, chan->desc_pool_p); The arguments desc_size and ZYNQMP_DMA_NUM_DESCS were 32 bit. Though this overflow condition is not observed but it is a potential problem in the case of 32-bit multiplication. Hence fix it by changing the desc_size data type to size_t. In addition to coverity fix it also reuse ZYNQMP_DMA_DESC_SIZE macro in dma_alloc_coherent API argument. Addresses-Coverity: Event overflow_before_widen. Signed-off-by: Radhey Shyam Pandey Link: https://lore.kernel.org/r/1652166762-18317-2-git-send-email-radhey.shyam.pandey@xilinx.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/xilinx/zynqmp_dma.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c index 84009c5e0f33..b61d0c79dffb 100644 --- a/drivers/dma/xilinx/zynqmp_dma.c +++ b/drivers/dma/xilinx/zynqmp_dma.c @@ -232,7 +232,7 @@ struct zynqmp_dma_chan { bool is_dmacoherent; struct tasklet_struct tasklet; bool idle; - u32 desc_size; + size_t desc_size; bool err; u32 bus_width; u32 src_burst_len; @@ -489,7 +489,8 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan) } chan->desc_pool_v = dma_alloc_coherent(chan->dev, - (2 * chan->desc_size * ZYNQMP_DMA_NUM_DESCS), + (2 * ZYNQMP_DMA_DESC_SIZE(chan) * + ZYNQMP_DMA_NUM_DESCS), &chan->desc_pool_p, GFP_KERNEL); if (!chan->desc_pool_v) return -ENOMEM; -- 2.35.1