dmaengine: avoid map_cnt overflow with CONFIG_DMA_ENGINE_RAID
authorZi Yan <zi.yan@cs.rutgers.edu>
Mon, 8 Jan 2018 15:50:50 +0000 (10:50 -0500)
committerVinod Koul <vinod.koul@intel.com>
Mon, 12 Feb 2018 03:48:56 +0000 (09:18 +0530)
When CONFIG_DMA_ENGINE_RAID is enabled, unmap pool size can reach to
256. But in struct dmaengine_unmap_data, map_cnt is only u8, wrapping
to 0, if the unmap pool is maximally used. This triggers BUG() when
struct dmaengine_unmap_data is freed. Use u16 to fix the problem.

Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
include/linux/dmaengine.h

index f838764993eb366d8813052835e58c6a60f57aca..861be5cab1dff22b5ae2892eab265585a0c2de29 100644 (file)
@@ -470,7 +470,11 @@ typedef void (*dma_async_tx_callback_result)(void *dma_async_param,
                                const struct dmaengine_result *result);
 
 struct dmaengine_unmap_data {
+#if IS_ENABLED(CONFIG_DMA_ENGINE_RAID)
+       u16 map_cnt;
+#else
        u8 map_cnt;
+#endif
        u8 to_cnt;
        u8 from_cnt;
        u8 bidi_cnt;