Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Damien Le Moal <dlemoal@kernel.org>,
	Niklas Cassel <cassel@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Vinod Koul <vkoul@kernel.org>,
	Nikita Shubin <nikita.shubin@maquefel.me>,
	Sergey Shtylyov <s.shtylyov@omp.ru>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ata: pata_ep93xx: fix double free and ERR_PTR dereference on DMA error path
Date: Mon,  1 Jun 2026 11:33:59 -0700	[thread overview]
Message-ID: <20260601183359.11343-1-rosenp@gmail.com> (raw)

If dma_request_chan(&pdev->dev, "tx") fails during ep93xx_pata_dma_init(),
drv_data->dma_tx_channel holds an ERR_PTR. The error path at
fail_release_rx releases dma_rx_channel but does not NULL the pointer,
then falls through to ep93xx_pata_release_dma() which attempts to release
dma_rx_channel again (double free) and calls dma_release_channel() on the
ERR_PTR dma_tx_channel (invalid pointer dereference).

Fix by NULLing dma_tx_channel before falling through to
ep93xx_pata_release_dma(), which will then clean up dma_rx_channel.

Fixes: 9963113e3a92 ("ata: pata_ep93xx: add device tree support")
Assisted-by: Opencode:Big-Pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/ata/pata_ep93xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/pata_ep93xx.c b/drivers/ata/pata_ep93xx.c
index b2b9e0058333..aa6f8172925d 100644
--- a/drivers/ata/pata_ep93xx.c
+++ b/drivers/ata/pata_ep93xx.c
@@ -688,7 +688,7 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data)
 	return 0;
 
 fail_release_rx:
-	dma_release_channel(drv_data->dma_rx_channel);
+	drv_data->dma_tx_channel = NULL;
 fail_release_dma:
 	ep93xx_pata_release_dma(drv_data);
 
-- 
2.54.0


             reply	other threads:[~2026-06-01 18:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 18:33 Rosen Penev [this message]
2026-06-01 18:44 ` [PATCH] ata: pata_ep93xx: fix double free and ERR_PTR dereference on DMA error path sashiko-bot
2026-06-01 19:05   ` Rosen Penev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260601183359.11343-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=arnd@arndb.de \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nikita.shubin@maquefel.me \
    --cc=s.shtylyov@omp.ru \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox