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 366A01FB4 for ; Fri, 3 Feb 2023 10:23:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7086FC433EF; Fri, 3 Feb 2023 10:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675419803; bh=nyx8R1iatVI0dqQqG052dXSkuLS+LDgoROTQpI0M2Ow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EOQsXxCM4QwATkfvd9CwEsprWSUjfShwc+bQMNXBm/gbcQDeZRWZgJ6Enxr3ZSmah BdfVpVQp+j8wInTpGZIN4hEmHhDZBIfQ+ioTMK4NAMU5QAGg2kaO75J1OQp2zqHGeR chgO2CLoy8z7BIpoy/vQX48crVk3AXFwhnxRq+Fo= 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.10 6/9] dmaengine: imx-sdma: Fix a possible memory leak in sdma_transfer_init Date: Fri, 3 Feb 2023 11:13:35 +0100 Message-Id: <20230203101006.684979107@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203101006.422534094@linuxfoundation.org> References: <20230203101006.422534094@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 2283dcd8bf91..6514db824473 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1363,10 +1363,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