Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp813491imu; Tue, 11 Dec 2018 08:00:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/WjejLUpj9BDelrDLmcOA7apQ8ztlFtEl9CNyuchGKJUOtdmJnn/peUIYIVY7DjqU5ZVaBp X-Received: by 2002:a62:2044:: with SMTP id g65mr16698151pfg.127.1544544019054; Tue, 11 Dec 2018 08:00:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544544019; cv=none; d=google.com; s=arc-20160816; b=Ncbolaou+DeTL9gfjrwpR/PnyL8/4jbEagdZcWUuzQwu77J8y4Emp90nrBivVsRYVk 59SMJ8L6MkwXs5oB8oKsW5IN58u3xsOUQup14PRIqjjVr9e63TrgYn6Vt+Mim0/zUl6V hreeOG3fE8rXQRpEFoHj09hpunff4WdJYdGjsqaKo2lO1bDfcDt7MCu0XjlVvQFw6idq 48FlcxdWabmZeEmvGextB/3tOoUketmO/5aOHjlLnbNmu1k/KJs2m7H6aBj+r7J5m4B6 yAcsOFP0M10nY9xKxpckpWD1bOjNHrqeXHS+pIBA4M8GRWJvR4F9LlQ2mvp2eLhYIavm 79Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CkBGdEaeAM8ZWAdALEn7oq4LuMXkVlqEmTc6GFz+Ikw=; b=qGAR+ILJeMbiTRbb8x4U+xn4/oEc7mEuh+I1R5rgdjBDtYOr9AIBSK+KaAwlI0+vSG TOPFq+7qYBJ0ukLFiFZZvv4UYXci2PLUBsPhJpRc0CYO5mZEiugLHQ9lhSSZlV1O8jbK w23qxiaClEB7QF7cSJqguwFxGvb5o9YCgGHvWK6jlFR/hZDPu8ngjaDY1evkzgMiDUxz HA0HbC8QksHQUstvIGGxrWcPdaOmKezQtvJskrD0I3CuEgOnEV4xXLDZ/VF7Cm90XNp/ fTcdCWFb+Q9jU3kgF7SY0H1Ked/bYk2wiDI8E7hfD0PVQo/ct7VwF0qLk5CAsksvLa0J fjYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FD2ZOt7I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si12504033pgj.543.2018.12.11.08.00.04; Tue, 11 Dec 2018 08:00:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FD2ZOt7I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730792AbeLKP5V (ORCPT + 99 others); Tue, 11 Dec 2018 10:57:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:46276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730784AbeLKP5S (ORCPT ); Tue, 11 Dec 2018 10:57:18 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BC302146E; Tue, 11 Dec 2018 15:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543837; bh=o1B4JZvu3F0P3i/OzYIOTH2Bj56qHkAiFI4w9LLgEzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FD2ZOt7I/Bue2HnJjdg/oCYeeLQEsbnSem9Gj/1aODKjBNM0MCljF6Ch3H1X1YqWm 5iOJMBNOzAgv4g/EXlM60iRiyhK1ydvOQevEo2A+OccSGUPTuxuFup2XNeue+yuV2F s7MsaZk9neW4i16Z5yV1mbAXNF7u9IGegenaqt20= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lucas Stach , Robin Gong , Vinod Koul Subject: [PATCH 4.19 084/118] Revert "dmaengine: imx-sdma: alloclate bd memory from dma pool" Date: Tue, 11 Dec 2018 16:41:43 +0100 Message-Id: <20181211151647.662325438@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151644.216668863@linuxfoundation.org> References: <20181211151644.216668863@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lucas Stach commit ebb853b1bd5f659b92c71dc6a9de44cfc37c78c0 upstream. This reverts commit fe5b85c656bc. The SDMA engine needs the descriptors to be contiguous in memory. As the dma pool API is only able to provide a single descriptor per alloc invocation there is no guarantee that multiple descriptors satisfy this requirement. Also the code in question is broken as it only allocates memory for a single descriptor, without looking at the number of descriptors required for the transfer, leading to out-of-bounds accesses when the descriptors are written. Signed-off-by: Lucas Stach Signed-off-by: Robin Gong Cc: stable Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/imx-sdma.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -376,7 +375,6 @@ struct sdma_channel { u32 shp_addr, per_addr; enum dma_status status; struct imx_dma_data data; - struct dma_pool *bd_pool; }; #define IMX_DMA_SG_LOOP BIT(0) @@ -1192,10 +1190,11 @@ out: static int sdma_alloc_bd(struct sdma_desc *desc) { + u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor); int ret = 0; - desc->bd = dma_pool_alloc(desc->sdmac->bd_pool, GFP_ATOMIC, - &desc->bd_phys); + desc->bd = dma_zalloc_coherent(NULL, bd_size, &desc->bd_phys, + GFP_ATOMIC); if (!desc->bd) { ret = -ENOMEM; goto out; @@ -1206,7 +1205,9 @@ out: static void sdma_free_bd(struct sdma_desc *desc) { - dma_pool_free(desc->sdmac->bd_pool, desc->bd, desc->bd_phys); + u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor); + + dma_free_coherent(NULL, bd_size, desc->bd, desc->bd_phys); } static void sdma_desc_free(struct virt_dma_desc *vd) @@ -1272,10 +1273,6 @@ static int sdma_alloc_chan_resources(str if (ret) goto disable_clk_ahb; - sdmac->bd_pool = dma_pool_create("bd_pool", chan->device->dev, - sizeof(struct sdma_buffer_descriptor), - 32, 0); - return 0; disable_clk_ahb: @@ -1304,9 +1301,6 @@ static void sdma_free_chan_resources(str clk_disable(sdma->clk_ipg); clk_disable(sdma->clk_ahb); - - dma_pool_destroy(sdmac->bd_pool); - sdmac->bd_pool = NULL; } static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac,