Skip to content

Commit 23f963e

Browse files
Matthias KaehlckeVinod Koul
authored andcommitted
dmaengine: Fix array index out of bounds warning in __get_unmap_pool()
This fixes the following warning when building with clang and CONFIG_DMA_ENGINE_RAID=n : drivers/dma/dmaengine.c:1102:11: error: array index 2 is past the end of the array (which contains 1 element) [-Werror,-Warray-bounds] return &unmap_pool[2]; ^ ~ drivers/dma/dmaengine.c:1083:1: note: array 'unmap_pool' declared here static struct dmaengine_unmap_pool unmap_pool[] = { ^ drivers/dma/dmaengine.c:1104:11: error: array index 3 is past the end of the array (which contains 1 element) [-Werror,-Warray-bounds] return &unmap_pool[3]; ^ ~ drivers/dma/dmaengine.c:1083:1: note: array 'unmap_pool' declared here static struct dmaengine_unmap_pool unmap_pool[] = { Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
1 parent 2201ac6 commit 23f963e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/dma/dmaengine.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,12 +1108,14 @@ static struct dmaengine_unmap_pool *__get_unmap_pool(int nr)
11081108
switch (order) {
11091109
case 0 ... 1:
11101110
return &unmap_pool[0];
1111+
#if IS_ENABLED(CONFIG_DMA_ENGINE_RAID)
11111112
case 2 ... 4:
11121113
return &unmap_pool[1];
11131114
case 5 ... 7:
11141115
return &unmap_pool[2];
11151116
case 8:
11161117
return &unmap_pool[3];
1118+
#endif
11171119
default:
11181120
BUG();
11191121
return NULL;

0 commit comments

Comments
 (0)