Skip to contentSkip to conversation

tty: serial: fsl_lpuart: Check the return value of dmaengine_tx_status

PATCH In review Sherry Sun 3 participants 3 messages May 22, 2023 TTY layer and serial drivers

lore
Share & tools
lore

Sherry Sun

author
#0 lore raw

PATCH 1/1 tty: serial: fsl_lpuart: Check the return value of dmaengine_tx_status

Coverity reports the Unchecked return value (CHECKED_RETURN) warning:
Calling dmaengine_tx_status without checking return value.

So here add the return value check for dmaengine_tx_status() function to make coverity happy.

Fixes cf9aa72d2f91 ("tty: serial: fsl_lpuart: optimize the timer based EOP logic")
---
 drivers/tty/serial/fsl_lpuart.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/fsl_lpuart.c +7 -1
index 92a3bd0f4158..f2a47a8c5b85 100644
@@ -1286,13 +1286,19 @@ static void lpuart_dma_rx_complete(void *arg)
 static void lpuart_timer_func(struct timer_list *t)
 {
 	struct lpuart_port *sport = from_timer(sport, t, lpuart_timer);
+	enum dma_status dmastat;
 	struct dma_chan *chan = sport->dma_rx_chan;
 	struct circ_buf *ring = &sport->rx_ring;
 	struct dma_tx_state state;
 	unsigned long flags;
 	int count;
 
-	dmaengine_tx_status(chan, sport->dma_rx_cookie, &state);
+	dmastat = dmaengine_tx_status(chan, sport->dma_rx_cookie, &state);
+	if (dmastat == DMA_ERROR) {
+		dev_err(sport->port.dev, "Rx DMA transfer failed!\n");
+		return;
+	}
+
 	ring->head = sport->rx_sgl.length - state.residue;
 	count = CIRC_CNT(ring->head, ring->tail, sport->rx_sgl.length);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 29 lines

-----Original Message-----
From: Sherry Sun <[email protected]>
Sent: Sunday, May 21, 2023 9:51 PM
To: [email protected]; [email protected]; Shenwei Wang <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>
Subject: [PATCH] tty: serial: fsl_lpuart: Check the return value of dmaengine_tx_status

Coverity reports the Unchecked return value (CHECKED_RETURN) warning:
Calling dmaengine_tx_status without checking return value.

So here add the return value check for dmaengine_tx_status() function to make coverity happy.

Fixes cf9aa72d2f91 ("tty: serial: fsl_lpuart: optimize the timer based EOP logic")
---
 drivers/tty/serial/fsl_lpuart.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/fsl_lpuart.c index renamed from drivers/tty/serial/fsl_lpuart.c +0 -0

92a3bd0f4158..f2a47a8c5b85 100644

drivers/tty/serial/fsl_lpuart.c static void lpuart_dma_rx_complete(void *arg) · line 1288

Quoted 3 lines
drivers/tty/serial/fsl_lpuart.c +1 -0
@@ -1286,13 +1286,19 @@ static void lpuart_dma_rx_complete(void *arg)
 static void lpuart_timer_func(struct timer_list *t)  {
 	struct lpuart_port *sport = from_timer(sport, t, lpuart_timer);
+	enum dma_status dmastat;

Should be reverse Christmas tree order.

Regards,
Shenwei

Quoted 18 lines
drivers/tty/serial/fsl_lpuart.c +6 -2
 	struct dma_chan *chan = sport->dma_rx_chan;
 	struct circ_buf *ring = &sport->rx_ring;
 	struct dma_tx_state state;
 	unsigned long flags;
 	int count;
 
-	dmaengine_tx_status(chan, sport->dma_rx_cookie, &state);
+	dmastat = dmaengine_tx_status(chan, sport->dma_rx_cookie, &state);
+	if (dmastat == DMA_ERROR) {
+		dev_err(sport->port.dev, "Rx DMA transfer failed!\n");
+		return;
+	}
+
 	ring->head = sport->rx_sgl.length - state.residue;
 	count = CIRC_CNT(ring->head, ring->tail, sport->rx_sgl.length);
 
--

2.17.1

#2 lore raw
Quoted 24 lines · Shenwei Wang
Quoted 24 lines

-----Original Message-----
From: Sherry Sun <[email protected]>
Sent: Sunday, May 21, 2023 9:51 PM
To: [email protected]; [email protected]; Shenwei Wang <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>
Subject: [PATCH] tty: serial: fsl_lpuart: Check the return value of dmaengine_tx_status

Coverity reports the Unchecked return value (CHECKED_RETURN) warning:
Calling dmaengine_tx_status without checking return value.

So here add the return value check for dmaengine_tx_status() function to make coverity happy.

Fixes cf9aa72d2f91 ("tty: serial: fsl_lpuart: optimize the timer based EOP logic")
---
 drivers/tty/serial/fsl_lpuart.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 10 lines

drivers/tty/serial/fsl_lpuart.c static void lpuart_dma_rx_complete(void *arg) · line 1288

Quoted 8 lines
drivers/tty/serial/fsl_lpuart.c index renamed from drivers/tty/serial/fsl_lpuart.c +0 -0

92a3bd0f4158..f2a47a8c5b85 100644

drivers/tty/serial/fsl_lpuart.c +1 -0
@@ -1286,13 +1286,19 @@ static void lpuart_dma_rx_complete(void *arg)
 static void lpuart_timer_func(struct timer_list *t)  {
 	struct lpuart_port *sport = from_timer(sport, t, lpuart_timer);
+	enum dma_status dmastat;

Should be reverse Christmas tree order.

Not a requirement at all, please don't force it.

thanks,

greg k-h