Skip to content

Commit 6758dda

Browse files
alexandrebelloniVinod Koul
authored andcommitted
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>
1 parent cfc6abc commit 6758dda

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎drivers/dma/at_hdmac.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,16 @@ static int atc_get_bytes_left(struct dma_chan *chan)
294294
ret = -EINVAL;
295295
goto out;
296296
}
297-
atchan->remain_desc -= (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
298-
<< (desc_first->tx_width);
299-
if (atchan->remain_desc < 0) {
297+
298+
count = (desc_cur->lli.ctrla & ATC_BTSIZE_MAX)
299+
<< desc_first->tx_width;
300+
if (atchan->remain_desc < count) {
300301
ret = -EINVAL;
301302
goto out;
302-
} else {
303-
ret = atchan->remain_desc;
304303
}
304+
305+
atchan->remain_desc -= count;
306+
ret = atchan->remain_desc;
305307
} else {
306308
/*
307309
* Get residual bytes when current

0 commit comments

Comments
 (0)