From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70D171FBC for ; Fri, 3 Feb 2023 10:30:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE4E0C433EF; Fri, 3 Feb 2023 10:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675420201; bh=KDl2zacnSK0FLUxtKWcIV32UB7/5CvDpOu567wZ5mOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rzYnJEyCU7o4HjWR902uP0pmVONaqFJc2CXzx19Y6h0B/bIaM449fNNelEfrhDceK 8ri8LIUBU2ibxm4o/UoZILVzZGaRHW/gov/Y3TqF2hhi9jMqFrUfSiDI39KZq7C1j5 l5Kh8wq1zv6zml99TQrYg6PqKtkEwyyefzA4Sl+k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hui Wang , Sascha Hauer , Vinod Koul , Sasha Levin Subject: [PATCH 5.4 113/134] dmaengine: imx-sdma: Fix a possible memory leak in sdma_transfer_init Date: Fri, 3 Feb 2023 11:13:38 +0100 Message-Id: <20230203101028.919903470@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203101023.832083974@linuxfoundation.org> References: <20230203101023.832083974@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Hui Wang [ Upstream commit 1417f59ac0b02130ee56c0c50794b9b257be3d17 ] If the function sdma_load_context() fails, the sdma_desc will be freed, but the allocated desc->bd is forgot to be freed. We already met the sdma_load_context() failure case and the log as below: [ 450.699064] imx-sdma 30bd0000.dma-controller: Timeout waiting for CH0 ready ... In this case, the desc->bd will not be freed without this change. Signed-off-by: Hui Wang Reviewed-by: Sascha Hauer Link: https://lore.kernel.org/r/20221130090800.102035-1-hui.wang@canonical.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/imx-sdma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 8ec7a7041e84..8dbff2f6c3b8 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1360,10 +1360,12 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, sdma_config_ownership(sdmac, false, true, false); if (sdma_load_context(sdmac)) - goto err_desc_out; + goto err_bd_out; return desc; +err_bd_out: + sdma_free_bd(desc); err_desc_out: kfree(desc); err_out: -- 2.39.0