Skip to content

Commit 9168615

Browse files
Xiaomeng Tonggregkh
authored andcommitted
dma: at_xdmac: fix a missing check on list iterator
commit 206680c upstream. The bug is here: __func__, desc, &desc->tx_dma_desc.phys, ret, cookie, residue); The list iterator 'desc' will point to a bogus position containing HEAD if the list is empty or no element is found. To avoid dev_dbg() prints a invalid address, use a new variable 'iter' as the list iterator, while use the origin variable 'desc' as a dedicated pointer to point to the found element. Cc: stable@vger.kernel.org Fixes: 82e2424 ("dmaengine: xdmac: fix print warning on dma_addr_t variable") Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com> Link: https://lore.kernel.org/r/20220327061154.4867-1-xiam0nd.tong@gmail.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3cca43b commit 9168615

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/dma/at_xdmac.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
13921392
{
13931393
struct at_xdmac_chan *atchan = to_at_xdmac_chan(chan);
13941394
struct at_xdmac *atxdmac = to_at_xdmac(atchan->chan.device);
1395-
struct at_xdmac_desc *desc, *_desc;
1395+
struct at_xdmac_desc *desc, *_desc, *iter;
13961396
struct list_head *descs_list;
13971397
enum dma_status ret;
13981398
int residue, retry;
@@ -1507,11 +1507,13 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
15071507
* microblock.
15081508
*/
15091509
descs_list = &desc->descs_list;
1510-
list_for_each_entry_safe(desc, _desc, descs_list, desc_node) {
1511-
dwidth = at_xdmac_get_dwidth(desc->lld.mbr_cfg);
1512-
residue -= (desc->lld.mbr_ubc & 0xffffff) << dwidth;
1513-
if ((desc->lld.mbr_nda & 0xfffffffc) == cur_nda)
1510+
list_for_each_entry_safe(iter, _desc, descs_list, desc_node) {
1511+
dwidth = at_xdmac_get_dwidth(iter->lld.mbr_cfg);
1512+
residue -= (iter->lld.mbr_ubc & 0xffffff) << dwidth;
1513+
if ((iter->lld.mbr_nda & 0xfffffffc) == cur_nda) {
1514+
desc = iter;
15141515
break;
1516+
}
15151517
}
15161518
residue += cur_ubc << dwidth;
15171519

0 commit comments

Comments
 (0)