summaryrefslogtreecommitdiffstats
path: root/drivers/dma/at_hdmac.c
diff options
context:
space:
mode:
authorAlexandre Belloni2014-08-01 18:51:46 +0200
committerVinod Koul2014-08-07 18:22:27 +0200
commit6758ddafad55fc8e665bb03ff103d3e410483fe9 (patch)
tree9f6455b28f7d442029844b505fe03a30cb012520 /drivers/dma/at_hdmac.c
parentdmaengine: nbpfaxi: don't build this driver where it cannot be used (diff)
downloadkernel-qcow2-linux-6758ddafad55fc8e665bb03ff103d3e410483fe9.tar.gz
kernel-qcow2-linux-6758ddafad55fc8e665bb03ff103d3e410483fe9.tar.xz
kernel-qcow2-linux-6758ddafad55fc8e665bb03ff103d3e410483fe9.zip
dma: at_hdmac: fix invalid remaining bytes detection
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> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/at_hdmac.c')
-rw-r--r--drivers/dma/at_hdmac.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index d20ab1b73a3a..ca9dd2613283 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