From patchwork Sat Dec 19 12:58:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 345971 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3011361jai; Sat, 19 Dec 2020 05:07:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHql1F2ID36g3ZWv3q5JLhTTDfa+/hLIvStMI8FMXf4VbgwLR61q0G3scH+C/hCIc3BR0J X-Received: by 2002:a50:9ea4:: with SMTP id a33mr8682239edf.70.1608383266217; Sat, 19 Dec 2020 05:07:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608383266; cv=none; d=google.com; s=arc-20160816; b=W+YHHBcet1OWfkWoK3lax8cktU7L7R+TaTkV3Nh5qTMnDyzycH8dxw1z8D3nR2BcT2 H8vI+mDjb5OtXEHcz8uWGye968Td1VJ0Xad2kk30deN2nlHq6Rznb4ij89wzN/d+TNJb Fin1pKEFOBZcn8FYV7SPBRa9kEY9aZEWHvHxVDBqzHLZH5qdzz1R8BtjZfbyxNrh9feM IqG9YCJ1U6QX2On5t5f8CXe7ArN1R4WWZX4XLGGLAZZStUJG9Ld76J+AVaS5dHsBIZ4F hWn2mXQ1D+nj5f9aH5UK0Y2CUIbSLMtr5IEA0mCD0xbGOCsMsZzMefQntF+K7OWQapUA WbaA== 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; bh=Lf3AbmSOazcEUNo8yi/YzI1kyEiEIvV6DTg4l6+mdzo=; b=jWeTG7kPBL6W/jqhiizeo4NZ1eDGhsGgICuGcoKBYkdOEwoWb3maq2+SStxWvpqv4+ 9q5oaQpzRNw4jyTmog7//htLwRfcKofefOrVk9JHQLb+jHC2FbhOLjqzgYWecfFdHx8O 8LGdRhloRQ4zykDN3C2D5cXH1xVq0s6aVENyHzVIElstxOV4U9nTxgE5toJayEFigiIl FfFbdmdiE9HSYdho+1oGHm62HTRPQVT39b/cmTWwl2eJnj9gGXHOUraAgJhRMYeYxdRY 0MYg1NAmcNH12Eryq1yKsTQUDGGe2nHf8OjD8kw7APIJqyNNC+cxacygVe8154Ws6ogG RMpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g25si6251070ejp.67.2020.12.19.05.07.46; Sat, 19 Dec 2020 05:07:46 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727651AbgLSM6e (ORCPT + 14 others); Sat, 19 Dec 2020 07:58:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:44716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727633AbgLSM6d (ORCPT ); Sat, 19 Dec 2020 07:58:33 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Boyd , Sujit Kautkar , Alex Elder , Bjorn Andersson , Jakub Kicinski Subject: [PATCH 5.9 03/49] net: ipa: pass the correct size when freeing DMA memory Date: Sat, 19 Dec 2020 13:58:07 +0100 Message-Id: <20201219125344.843872853@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201219125344.671832095@linuxfoundation.org> References: <20201219125344.671832095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alex Elder [ Upstream commit 1130b252480f3c98cf468e78c1c5c516b390a29c ] When the coherent memory is freed in gsi_trans_pool_exit_dma(), we are mistakenly passing the size of a single element in the pool rather than the actual allocated size. Fix this bug. Fixes: 9dd441e4ed575 ("soc: qcom: ipa: GSI transactions") Reported-by: Stephen Boyd Tested-by: Sujit Kautkar Signed-off-by: Alex Elder Reviewed-by: Bjorn Andersson Link: https://lore.kernel.org/r/20201203215106.17450-1-elder@linaro.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ipa/gsi_trans.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -157,6 +157,9 @@ int gsi_trans_pool_init_dma(struct devic /* The allocator will give us a power-of-2 number of pages. But we * can't guarantee that, so request it. That way we won't waste any * memory that would be available beyond the required space. + * + * Note that gsi_trans_pool_exit_dma() assumes the total allocated + * size is exactly (count * size). */ total_size = get_order(total_size) << PAGE_SHIFT; @@ -176,7 +179,9 @@ int gsi_trans_pool_init_dma(struct devic void gsi_trans_pool_exit_dma(struct device *dev, struct gsi_trans_pool *pool) { - dma_free_coherent(dev, pool->size, pool->base, pool->addr); + size_t total_size = pool->count * pool->size; + + dma_free_coherent(dev, total_size, pool->base, pool->addr); memset(pool, 0, sizeof(*pool)); }