Commit 6758ddaf authored by Alexandre Belloni's avatar Alexandre Belloni Committed by Vinod Koul

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: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent cfc6abc3
...@@ -294,14 +294,16 @@ static int atc_get_bytes_left(struct dma_chan *chan) ...@@ -294,14 +294,16 @@ static int atc_get_bytes_left(struct dma_chan *chan)
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
atchan->remain_desc -= (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
<< (desc_first->tx_width); count = (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
if (atchan->remain_desc < 0) { << desc_first->tx_width;
if (atchan->remain_desc < count) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} else {
ret = atchan->remain_desc;
} }
atchan->remain_desc -= count;
ret = atchan->remain_desc;
} else { } else {
/* /*
* Get residual bytes when current * Get residual bytes when current
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment