From patchwork Fri Feb 24 15:22:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Povi=C5=A1er?= X-Patchwork-Id: 13151398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13569C61DA3 for ; Fri, 24 Feb 2023 15:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W3l1Bb4SpVvkbQ8+zUFRKzluYo8FtdzH05k91Qi6GHs=; b=E/97Fq1ffHRVnI WnkuQDWCPE36+pImQ7/oXtKdgMMUcY5u/ukPEmN8SUYITlZF0BwS5BmPd//baPdxaCuZgkWqvQvxE SwqQCifqvIESwhesjKo4v9bTmz7ZodPc8trsnyWibJq2i9UB+Ei1Kx1M8F0xgj19YxpW0BXDz/hW6 1N5oJu5RFqNtj1fUMIUk2hFWiyhU4Cw5ffVt8MPwQz5s7gFynVaH2tnk+r1LTOS2cgeZpOAE965Tc 8ur3HnDDMbMIalk3O6c2p1vZqZ3HTZzd0C0dlKgtX85wPsX2cm9dCy2RmwsOrTo6fDpjJDDyB50we EVrHGmWo1rZrrzI97C7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVZuh-002wk3-7x; Fri, 24 Feb 2023 15:23:11 +0000 Received: from hutie.ust.cz ([185.8.165.127]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVZu5-002wUM-O2 for linux-arm-kernel@lists.infradead.org; Fri, 24 Feb 2023 15:22:35 +0000 From: =?utf-8?q?Martin_Povi=C5=A1er?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1677252145; bh=StaFikSjZpFQ+BUcIlQfwrxM+sCnU+rvBEoVvGQ2nmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fOvbi5u7TfZbdRb/5lxtFwcD+ebCgEW+egwfuLYdhfzxpB2grc3CsYFX5m3JosTZ3 5CP7I59IxQyKuSrYvD7i+g0nm3Z7Anzbz6LcVbPDatTuX7bCwQrAa765yoNtapNLkx VYNi76Ina7OQb60oYtDZ5wzW7ec+E3dPHKVJiV+4= To: Hector Martin , Sven Peter , Vinod Koul Cc: Alyssa Rosenzweig , =?utf-8?q?Martin_Povi=C5=A1er?= , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed Date: Fri, 24 Feb 2023 16:22:21 +0100 Message-Id: <20230224152222.26732-2-povik+lin@cutebit.org> In-Reply-To: <20230224152222.26732-1-povik+lin@cutebit.org> References: <20230224152222.26732-1-povik+lin@cutebit.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230224_072233_981536_BAD6D5A7 X-CRM114-Status: GOOD ( 10.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In terminate_all we should queue up all submitted descriptors to be freed. We do that for the content of the 'issued' and 'submitted' lists, but the 'current_tx' descriptor falls through the cracks as it's removed from the 'issued' list once it gets assigned to be the current descriptor. Explicitly queue up freeing of the 'current_tx' descriptor to address a memory leak that is otherwise present. Fixes: b127315d9a78 ("dmaengine: apple-admac: Add Apple ADMAC driver") Signed-off-by: Martin PoviĊĦer --- drivers/dma/apple-admac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c index 00cbfafe0ed9..497bb65b7d6d 100644 --- a/drivers/dma/apple-admac.c +++ b/drivers/dma/apple-admac.c @@ -512,7 +512,10 @@ static int admac_terminate_all(struct dma_chan *chan) admac_stop_chan(adchan); admac_reset_rings(adchan); - adchan->current_tx = NULL; + if (adchan->current_tx) { + list_add_tail(&adchan->current_tx->node, &adchan->to_free); + adchan->current_tx = NULL; + } /* * Descriptors can only be freed after the tasklet * has been killed (in admac_synchronize).