dmaengine: mv_xor_v2: properly handle wrapping in the array of HW descriptors
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Fri, 5 May 2017 09:57:45 +0000 (11:57 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jun 2017 13:05:57 +0000 (15:05 +0200)
commit67b1684c4a5e092263b2b9fc3670450eedb620cf
tree1ad5b30d36674093bf20c060e5d0e4da6712be8a
parentf08c84d4c7450135ccd90e7d4ce10335d998ea6f
dmaengine: mv_xor_v2: properly handle wrapping in the array of HW descriptors

commit 2aab4e18152cd30cb5d2f4c27629fc8a04aed979 upstream.

mv_xor_v2_tasklet() is looping over completed HW descriptors. Before the
loop, it initializes 'next_pending_hw_desc' to the first HW descriptor
to handle, and then the loop simply increments this point, without
taking care of wrapping when we reach the last HW descriptor. The
'pending_ptr' index was being wrapped back to 0 at the end, but it
wasn't used in each iteration of the loop to calculate
next_pending_hw_desc.

This commit fixes that, and makes next_pending_hw_desc a variable local
to the loop itself.

Fixes: 19a340b1a820 ("dmaengine: mv_xor_v2: new driver")
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/dma/mv_xor_v2.c