* [PATCHv2] dma: at_hdmac: fix invalid remaining bytes detection
@ 2014-08-01 16:51 ` Alexandre Belloni
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2014-08-01 16:51 UTC (permalink / raw)
To: Nicolas Ferre, Vinod Koul
Cc: Dan Williams, Ludovic Desroches, linux-arm-kernel, linux-kernel,
dmaengine, Alexandre Belloni
Found using smatch:
drivers/dma/at_hdmac.c:299 atc_get_bytes_left() warn: unsigned
'atchan->remain_desc' is never less than zero.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Changes in v2:
- remove unnecessary parentheses
drivers/dma/at_hdmac.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index c13a3bb0f594..adb0fbc63f16 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -294,14 +294,16 @@ static int atc_get_bytes_left(struct dma_chan *chan)
ret = -EINVAL;
goto out;
}
- atchan->remain_desc -= (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
- << (desc_first->tx_width);
- if (atchan->remain_desc < 0) {
+
+ count = (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
+ << desc_first->tx_width;
+ if (atchan->remain_desc < count) {
ret = -EINVAL;
goto out;
- } else {
- ret = atchan->remain_desc;
}
+
+ atchan->remain_desc -= count;
+ ret = atchan->remain_desc;
} else {
/*
* Get residual bytes when current
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCHv2] dma: at_hdmac: fix invalid remaining bytes detection
@ 2014-08-01 16:51 ` Alexandre Belloni
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2014-08-01 16:51 UTC (permalink / raw)
To: linux-arm-kernel
Found using smatch:
drivers/dma/at_hdmac.c:299 atc_get_bytes_left() warn: unsigned
'atchan->remain_desc' is never less than zero.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Changes in v2:
- remove unnecessary parentheses
drivers/dma/at_hdmac.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index c13a3bb0f594..adb0fbc63f16 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -294,14 +294,16 @@ static int atc_get_bytes_left(struct dma_chan *chan)
ret = -EINVAL;
goto out;
}
- atchan->remain_desc -= (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
- << (desc_first->tx_width);
- if (atchan->remain_desc < 0) {
+
+ count = (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
+ << desc_first->tx_width;
+ if (atchan->remain_desc < count) {
ret = -EINVAL;
goto out;
- } else {
- ret = atchan->remain_desc;
}
+
+ atchan->remain_desc -= count;
+ ret = atchan->remain_desc;
} else {
/*
* Get residual bytes when current
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCHv2] dma: at_hdmac: fix invalid remaining bytes detection
2014-08-01 16:51 ` Alexandre Belloni
@ 2014-08-07 16:23 ` Vinod Koul
-1 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2014-08-07 16:23 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Nicolas Ferre, Dan Williams, Ludovic Desroches, linux-arm-kernel,
linux-kernel, dmaengine
On Fri, Aug 01, 2014 at 06:51:46PM +0200, Alexandre Belloni wrote:
> Found using smatch:
> drivers/dma/at_hdmac.c:299 atc_get_bytes_left() warn: unsigned
> 'atchan->remain_desc' is never less than zero.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCHv2] dma: at_hdmac: fix invalid remaining bytes detection
@ 2014-08-07 16:23 ` Vinod Koul
0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2014-08-07 16:23 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Aug 01, 2014 at 06:51:46PM +0200, Alexandre Belloni wrote:
> Found using smatch:
> drivers/dma/at_hdmac.c:299 atc_get_bytes_left() warn: unsigned
> 'atchan->remain_desc' is never less than zero.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-07 16:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-01 16:51 [PATCHv2] dma: at_hdmac: fix invalid remaining bytes detection Alexandre Belloni
2014-08-01 16:51 ` Alexandre Belloni
2014-08-07 16:23 ` Vinod Koul
2014-08-07 16:23 ` Vinod Koul
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.