Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4877444pjb; Mon, 27 Jul 2020 07:24:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzm7cCW5Kc0AFoksBtLJupHwLBtFpEQGKcQM/TbR1dn9E6lp504ZUQcqg7dUI3aUuKk6Bgo X-Received: by 2002:a17:906:53c1:: with SMTP id p1mr15252098ejo.15.1595859885644; Mon, 27 Jul 2020 07:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595859885; cv=none; d=google.com; s=arc-20160816; b=QDl/yLJdN/Q6iYerUacS7J77t3yupueskgJW9goInlR0rQnCevLJNVDdHOTqahtiPK 8oR/Cz5OEVHJcGkc0eaObKz2G/376WzXTNf2/SsEeM+RNNt00gply2FP3FcOV+lCMto6 VjFaI2RDlWOKFy7xv9oS3RL8VWa250UQkwj4ji0ZkTzhZqZsNLhz4T2Z8TKujku54t+/ tWm6rZES/K71BPUjV1uJUMV2UQRP6RafQbFBGedGpIf05fKtKJb4Z9SBDf2pboj3oykS kmUer1pmFfXEZ3kNYinw8I6l6VjVqtYSzwvULF4NuMkZL19V118uYVt+cMjwKHo2ozVE /++A== 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=WcSFL7rmShmyAhB/OVX8c9nRVrN24XRFqKz/jeyVojA=; b=gHha8JkGS3Yudu6VeTwErZmNF41Pttpg9LhOAQ9yIuXSV7K57UMomxiCu+rj/3ObA0 U50BMII9Hpr7IcO2X1dx555EWXyklCXRXDuNidbOXqN6bIVIf3OCfsydQRRNW1Is+S6p ijEeA0ceM9dJCYP4gvicydURxeVoR1ucOdjEK9cnaATFdQWiyKSAq+oUoycMo/fMy6Ht SMDlc6NzewJYE+X0EoJJZEWy4lfliCbGGHs1ZVVYBEkVqQMkuRtgncn5BXt0yiFWmFK7 C9ajjrHKo+m4VVZ7wF2ZQAexylHaDqY472Sjb6QQYCg1rkEnKtQXvNQQ5PmqVH7BRSxm gEAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DknD6UfP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si5699430ejt.451.2020.07.27.07.24.23; Mon, 27 Jul 2020 07:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DknD6UfP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732008AbgG0OXE (ORCPT + 99 others); Mon, 27 Jul 2020 10:23:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:52100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731997AbgG0OXA (ORCPT ); Mon, 27 Jul 2020 10:23:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 C18322070A; Mon, 27 Jul 2020 14:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859780; bh=9YDQ//FKRdwgXd+87UsMSe+Y6OxUfMAleBfFYEuz80c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DknD6UfPMITxxEHgQ6DhayQNGXlGsiKy9F3yYOWP18EmjZ0GDfaxAZEOpMhS+pXSu hMpkbjWx+DftUxdIWJ+xDPc1fYZyktd3Hr13E0cFh9EtizcO79NG8QfKPMvDXtNTKy lk5b0z1EqUzDokys4m2hUDLKJe2TR5z5ccU0n1Rw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Ujfalusi , Vinod Koul , Sasha Levin Subject: [PATCH 5.7 102/179] dmaengine: ti: k3-udma: Fix cleanup code for alloc_chan_resources Date: Mon, 27 Jul 2020 16:04:37 +0200 Message-Id: <20200727134937.621458979@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Peter Ujfalusi [ Upstream commit 5a9377cc7421b59b13c9b90b8dc0aca332a1c958 ] Some of the earlier errors should be sent to the error cleanup path to make sure that the uchan struct is reset, the dma_pool (if allocated) is released and memcpy channel pairs are released in a correct way. Signed-off-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20200527070612.636-2-peter.ujfalusi@ti.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/ti/k3-udma.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 7cab23fe5c73f..35f54a1af29d8 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -1773,7 +1773,8 @@ static int udma_alloc_chan_resources(struct dma_chan *chan) dev_err(ud->ddev.dev, "Descriptor pool allocation failed\n"); uc->use_dma_pool = false; - return -ENOMEM; + ret = -ENOMEM; + goto err_cleanup; } } @@ -1793,16 +1794,18 @@ static int udma_alloc_chan_resources(struct dma_chan *chan) ret = udma_get_chan_pair(uc); if (ret) - return ret; + goto err_cleanup; ret = udma_alloc_tx_resources(uc); - if (ret) - return ret; + if (ret) { + udma_put_rchan(uc); + goto err_cleanup; + } ret = udma_alloc_rx_resources(uc); if (ret) { udma_free_tx_resources(uc); - return ret; + goto err_cleanup; } uc->config.src_thread = ud->psil_base + uc->tchan->id; @@ -1820,10 +1823,8 @@ static int udma_alloc_chan_resources(struct dma_chan *chan) uc->id); ret = udma_alloc_tx_resources(uc); - if (ret) { - uc->config.remote_thread_id = -1; - return ret; - } + if (ret) + goto err_cleanup; uc->config.src_thread = ud->psil_base + uc->tchan->id; uc->config.dst_thread = uc->config.remote_thread_id; @@ -1840,10 +1841,8 @@ static int udma_alloc_chan_resources(struct dma_chan *chan) uc->id); ret = udma_alloc_rx_resources(uc); - if (ret) { - uc->config.remote_thread_id = -1; - return ret; - } + if (ret) + goto err_cleanup; uc->config.src_thread = uc->config.remote_thread_id; uc->config.dst_thread = (ud->psil_base + uc->rchan->id) | @@ -1858,7 +1857,9 @@ static int udma_alloc_chan_resources(struct dma_chan *chan) /* Can not happen */ dev_err(uc->ud->dev, "%s: chan%d invalid direction (%u)\n", __func__, uc->id, uc->config.dir); - return -EINVAL; + ret = -EINVAL; + goto err_cleanup; + } /* check if the channel configuration was successful */ @@ -1936,7 +1937,7 @@ err_psi_free: err_res_free: udma_free_tx_resources(uc); udma_free_rx_resources(uc); - +err_cleanup: udma_reset_uchan(uc); if (uc->use_dma_pool) { -- 2.25.1