mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmaengine: mv_xor: return descriptor to free pool on io_win failure
@ 2026-09-09 23:49 Rosen Penev
  2026-09-10  1:45 ` Frank Li
  2026-09-10 14:10 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Rosen Penev @ 2026-09-09 23:49 UTC (permalink / raw)
  To: dmaengine; +Cc: Vinod Koul, Frank Li, Stefan Roese, open list

When mv_xor_prep_dma_xor() allocates a descriptor slot and then
mv_xor_add_io_win() fails in the source-address loop, the slot
stays on the allocated list and is never reclaimed, leaking a
descriptor resource.

Return the slot to the free pool under the channel lock before
returning NULL on failure.

Fixes: 77ff7a706f01 ("mv_xor: Add support for IO (PCIe) src/dst areas")
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/dma/mv_xor.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 25ed61f1b089..dd4f150d5fb1 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -583,8 +583,13 @@ mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
 		while (src_cnt--) {
 			/* Check if a new window needs to get added for 'src' */
 			ret = mv_xor_add_io_win(mv_chan, src[src_cnt]);
-			if (ret)
+			if (ret) {
+				spin_lock_bh(&mv_chan->lock);
+				list_move_tail(&sw_desc->node,
+					       &mv_chan->free_slots);
+				spin_unlock_bh(&mv_chan->lock);
 				return NULL;
+			}
 			mv_desc_set_src_addr(sw_desc, src_cnt, src[src_cnt]);
 		}
 	}
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: mv_xor: return descriptor to free pool on io_win failure
  2026-09-09 23:49 [PATCH] dmaengine: mv_xor: return descriptor to free pool on io_win failure Rosen Penev
@ 2026-09-10  1:45 ` Frank Li
  2026-09-10 14:10 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2026-09-10  1:45 UTC (permalink / raw)
  To: Rosen Penev; +Cc: dmaengine, Vinod Koul, Frank Li, Stefan Roese, open list

On Wed, Sep 09, 2026 at 04:49:24PM -0700, Rosen Penev wrote:
> When mv_xor_prep_dma_xor() allocates a descriptor slot and then
> mv_xor_add_io_win() fails in the source-address loop, the slot
> stays on the allocated list and is never reclaimed, leaking a
> descriptor resource.
>
> Return the slot to the free pool under the channel lock before
> returning NULL on failure.
>
> Fixes: 77ff7a706f01 ("mv_xor: Add support for IO (PCIe) src/dst areas")
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/dma/mv_xor.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
> index 25ed61f1b089..dd4f150d5fb1 100644
> --- a/drivers/dma/mv_xor.c
> +++ b/drivers/dma/mv_xor.c
> @@ -583,8 +583,13 @@ mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
>  		while (src_cnt--) {
>  			/* Check if a new window needs to get added for 'src' */
>  			ret = mv_xor_add_io_win(mv_chan, src[src_cnt]);
> -			if (ret)
> +			if (ret) {
> +				spin_lock_bh(&mv_chan->lock);
> +				list_move_tail(&sw_desc->node,
> +					       &mv_chan->free_slots);
> +				spin_unlock_bh(&mv_chan->lock);
>  				return NULL;
> +			}
>  			mv_desc_set_src_addr(sw_desc, src_cnt, src[src_cnt]);
>  		}
>  	}
> --
> 2.55.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: mv_xor: return descriptor to free pool on io_win failure
  2026-09-09 23:49 [PATCH] dmaengine: mv_xor: return descriptor to free pool on io_win failure Rosen Penev
  2026-09-10  1:45 ` Frank Li
@ 2026-09-10 14:10 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2026-09-10 14:10 UTC (permalink / raw)
  To: dmaengine, Rosen Penev; +Cc: Frank Li, Stefan Roese, linux-kernel


On Wed, 09 Sep 2026 16:49:24 -0700, Rosen Penev wrote:
> When mv_xor_prep_dma_xor() allocates a descriptor slot and then
> mv_xor_add_io_win() fails in the source-address loop, the slot
> stays on the allocated list and is never reclaimed, leaking a
> descriptor resource.
> 
> Return the slot to the free pool under the channel lock before
> returning NULL on failure.
> 
> [...]

Applied, thanks!

[1/1] dmaengine: mv_xor: return descriptor to free pool on io_win failure
      commit: 5d5f4b3407d6ec86e76d094c332301135f493636

Best regards,
-- 
~Vinod



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-10 14:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09 23:49 [PATCH] dmaengine: mv_xor: return descriptor to free pool on io_win failure Rosen Penev
2026-09-10  1:45 ` Frank Li
2026-09-10 14:10 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®