Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [PATCH] mmc: sdio_uart: fix xmit_fifo leak when the port table is full
@ 2026-08-21 18:58 Felix Gu
  2026-09-10 16:05 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Gu @ 2026-08-21 18:58 UTC (permalink / raw)
  To: Ulf Hansson, Greg Kroah-Hartman, Alan Cox
  Cc: linux-mmc, linux-kernel, Felix Gu

sdio_uart_add_port() allocates the transmit fifo before claiming a
slot in sdio_uart_table[].  When all UART_NR slots are taken, it
returns -EBUSY with the fifo still allocated, but the probe error
path only kfree()s the port, leaking the transmit fifo.

Free the fifo in the failure path of sdio_uart_add_port() itself so
the function retains nothing on error.

Fixes: 8b197a5ce7a7 ("sdio_uart: Use kfifo instead of the messy circ stuff")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/mmc/core/sdio_uart.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c
index 7fd5dedf3ac0..705163c42972 100644
--- a/drivers/mmc/core/sdio_uart.c
+++ b/drivers/mmc/core/sdio_uart.c
@@ -104,6 +104,9 @@ static int sdio_uart_add_port(struct sdio_uart_port *port)
 	}
 	spin_unlock(&sdio_uart_table_lock);
 
+	if (ret)
+		kfifo_free(&port->xmit_fifo);
+
 	return ret;
 }
 

---
base-commit: 903c1cf6dff9964e71eda98a39e2e5d442050472
change-id: 20260822-sdio_uart-a702d7cc5eb4

Best regards,
--  
Felix Gu <ustc.gu@gmail.com>


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

* Re: [PATCH] mmc: sdio_uart: fix xmit_fifo leak when the port table is full
  2026-08-21 18:58 [PATCH] mmc: sdio_uart: fix xmit_fifo leak when the port table is full Felix Gu
@ 2026-09-10 16:05 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2026-09-10 16:05 UTC (permalink / raw)
  To: Felix Gu; +Cc: Ulf Hansson, Greg Kroah-Hartman, Alan Cox, linux-mmc,
	linux-kernel

On Fri, Aug 21, 2026 at 8:58 PM Felix Gu <ustc.gu@gmail.com> wrote:
>
> sdio_uart_add_port() allocates the transmit fifo before claiming a
> slot in sdio_uart_table[].  When all UART_NR slots are taken, it
> returns -EBUSY with the fifo still allocated, but the probe error
> path only kfree()s the port, leaking the transmit fifo.
>
> Free the fifo in the failure path of sdio_uart_add_port() itself so
> the function retains nothing on error.
>
> Fixes: 8b197a5ce7a7 ("sdio_uart: Use kfifo instead of the messy circ stuff")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>

Applied for fixes and by adding a stable tag, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/sdio_uart.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c
> index 7fd5dedf3ac0..705163c42972 100644
> --- a/drivers/mmc/core/sdio_uart.c
> +++ b/drivers/mmc/core/sdio_uart.c
> @@ -104,6 +104,9 @@ static int sdio_uart_add_port(struct sdio_uart_port *port)
>         }
>         spin_unlock(&sdio_uart_table_lock);
>
> +       if (ret)
> +               kfifo_free(&port->xmit_fifo);
> +
>         return ret;
>  }
>
>
> ---
> base-commit: 903c1cf6dff9964e71eda98a39e2e5d442050472
> change-id: 20260822-sdio_uart-a702d7cc5eb4
>
> Best regards,
> --
> Felix Gu <ustc.gu@gmail.com>
>

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21 18:58 [PATCH] mmc: sdio_uart: fix xmit_fifo leak when the port table is full Felix Gu
2026-09-10 16:05 ` Ulf Hansson

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