* [PATCH RESEND] usb: renesas_usbhs: Add error handling for usbhsf_fifo_select()
@ 2025-04-14 7:25 Wentao Liang
2025-04-14 7:38 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Wentao Liang @ 2025-04-14 7:25 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, linux-kernel, Wentao Liang, stable
In usbhsf_dcp_data_stage_prepare_pop(), the return value of
usbhsf_fifo_select() needs to be checked. A proper implementation
can be found in usbhsf_dma_try_pop_with_rx_irq().
Add an error check and jump to PIO pop when FIFO selection fails.
Fixes: 9e74d601de8a ("usb: gadget: renesas_usbhs: add data/status stage handler")
Cc: stable@vger.kernel.org # v3.2+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/usb/renesas_usbhs/fifo.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 10607e273879..6cc07ab4782d 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -466,6 +466,7 @@ static int usbhsf_dcp_data_stage_prepare_pop(struct usbhs_pkt *pkt,
struct usbhs_pipe *pipe = pkt->pipe;
struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv);
+ int ret;
if (usbhs_pipe_is_busy(pipe))
return 0;
@@ -480,10 +481,14 @@ static int usbhsf_dcp_data_stage_prepare_pop(struct usbhs_pkt *pkt,
usbhs_pipe_sequence_data1(pipe); /* DATA1 */
- usbhsf_fifo_select(pipe, fifo, 0);
+ ret = usbhsf_fifo_select(pipe, fifo, 0);
+ if (ret < 0)
+ goto usbhsf_pio_prepare_pop;
+
usbhsf_fifo_clear(pipe, fifo);
usbhsf_fifo_unselect(pipe, fifo);
+usbhsf_pio_prepare_pop:
/*
* change handler to PIO pop
*/
--
2.42.0.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] usb: renesas_usbhs: Add error handling for usbhsf_fifo_select()
2025-04-14 7:25 Wentao Liang
@ 2025-04-14 7:38 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2025-04-14 7:38 UTC (permalink / raw)
To: Wentao Liang; +Cc: linux-usb, linux-kernel, stable
On Mon, Apr 14, 2025 at 03:25:01PM +0800, Wentao Liang wrote:
> In usbhsf_dcp_data_stage_prepare_pop(), the return value of
> usbhsf_fifo_select() needs to be checked. A proper implementation
> can be found in usbhsf_dma_try_pop_with_rx_irq().
>
> Add an error check and jump to PIO pop when FIFO selection fails.
>
> Fixes: 9e74d601de8a ("usb: gadget: renesas_usbhs: add data/status stage handler")
> Cc: stable@vger.kernel.org # v3.2+
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/usb/renesas_usbhs/fifo.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Why is this RESEND? What happened to the first one?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH RESEND] usb: renesas_usbhs: Add error handling for usbhsf_fifo_select()
@ 2025-04-22 2:38 Wentao Liang
2025-04-25 11:01 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Wentao Liang @ 2025-04-22 2:38 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, linux-kernel, Wentao Liang, stable
In usbhsf_dcp_data_stage_prepare_pop(), the return value of
usbhsf_fifo_select() needs to be checked. A proper implementation
can be found in usbhsf_dma_try_pop_with_rx_irq().
Add an error check and jump to PIO pop when FIFO selection fails.
Fixes: 9e74d601de8a ("usb: gadget: renesas_usbhs: add data/status stage handler")
Cc: stable@vger.kernel.org # v3.2+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/usb/renesas_usbhs/fifo.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 10607e273879..6cc07ab4782d 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -466,6 +466,7 @@ static int usbhsf_dcp_data_stage_prepare_pop(struct usbhs_pkt *pkt,
struct usbhs_pipe *pipe = pkt->pipe;
struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv);
+ int ret;
if (usbhs_pipe_is_busy(pipe))
return 0;
@@ -480,10 +481,14 @@ static int usbhsf_dcp_data_stage_prepare_pop(struct usbhs_pkt *pkt,
usbhs_pipe_sequence_data1(pipe); /* DATA1 */
- usbhsf_fifo_select(pipe, fifo, 0);
+ ret = usbhsf_fifo_select(pipe, fifo, 0);
+ if (ret < 0)
+ goto usbhsf_pio_prepare_pop;
+
usbhsf_fifo_clear(pipe, fifo);
usbhsf_fifo_unselect(pipe, fifo);
+usbhsf_pio_prepare_pop:
/*
* change handler to PIO pop
*/
--
2.42.0.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] usb: renesas_usbhs: Add error handling for usbhsf_fifo_select()
2025-04-22 2:38 [PATCH RESEND] usb: renesas_usbhs: Add error handling for usbhsf_fifo_select() Wentao Liang
@ 2025-04-25 11:01 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2025-04-25 11:01 UTC (permalink / raw)
To: Wentao Liang; +Cc: linux-usb, linux-kernel, stable
On Tue, Apr 22, 2025 at 10:38:24AM +0800, Wentao Liang wrote:
> In usbhsf_dcp_data_stage_prepare_pop(), the return value of
> usbhsf_fifo_select() needs to be checked. A proper implementation
> can be found in usbhsf_dma_try_pop_with_rx_irq().
>
> Add an error check and jump to PIO pop when FIFO selection fails.
>
> Fixes: 9e74d601de8a ("usb: gadget: renesas_usbhs: add data/status stage handler")
> Cc: stable@vger.kernel.org # v3.2+
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/usb/renesas_usbhs/fifo.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
> index 10607e273879..6cc07ab4782d 100644
> --- a/drivers/usb/renesas_usbhs/fifo.c
> +++ b/drivers/usb/renesas_usbhs/fifo.c
> @@ -466,6 +466,7 @@ static int usbhsf_dcp_data_stage_prepare_pop(struct usbhs_pkt *pkt,
> struct usbhs_pipe *pipe = pkt->pipe;
> struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
> struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv);
> + int ret;
>
> if (usbhs_pipe_is_busy(pipe))
> return 0;
> @@ -480,10 +481,14 @@ static int usbhsf_dcp_data_stage_prepare_pop(struct usbhs_pkt *pkt,
>
> usbhs_pipe_sequence_data1(pipe); /* DATA1 */
>
> - usbhsf_fifo_select(pipe, fifo, 0);
> + ret = usbhsf_fifo_select(pipe, fifo, 0);
> + if (ret < 0)
> + goto usbhsf_pio_prepare_pop;
> +
> usbhsf_fifo_clear(pipe, fifo);
> usbhsf_fifo_unselect(pipe, fifo);
>
> +usbhsf_pio_prepare_pop:
> /*
> * change handler to PIO pop
> */
> --
> 2.42.0.windows.2
How was this tested? I still think this is wrong, as the cleanup does
not look correct.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-25 11:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22 2:38 [PATCH RESEND] usb: renesas_usbhs: Add error handling for usbhsf_fifo_select() Wentao Liang
2025-04-25 11:01 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2025-04-14 7:25 Wentao Liang
2025-04-14 7:38 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).