Commit 23f963e9 authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by Vinod Koul

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: default avatarMatthias Kaehlcke <mka@chromium.org>
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 2201ac61
...@@ -1108,12 +1108,14 @@ static struct dmaengine_unmap_pool *__get_unmap_pool(int nr) ...@@ -1108,12 +1108,14 @@ static struct dmaengine_unmap_pool *__get_unmap_pool(int nr)
switch (order) { switch (order) {
case 0 ... 1: case 0 ... 1:
return &unmap_pool[0]; return &unmap_pool[0];
#if IS_ENABLED(CONFIG_DMA_ENGINE_RAID)
case 2 ... 4: case 2 ... 4:
return &unmap_pool[1]; return &unmap_pool[1];
case 5 ... 7: case 5 ... 7:
return &unmap_pool[2]; return &unmap_pool[2];
case 8: case 8:
return &unmap_pool[3]; return &unmap_pool[3];
#endif
default: default:
BUG(); BUG();
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment