Skip to contentSkip to conversation

dma-engine: Fix array index out of bounds warning in __get_unmap_pool()

PATCH Applied Matthias Kaehlcke 3 participants 3 messages Mar 13, 2017 – Mar 14, 2017 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-engine: 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[] = {

---
 drivers/dma/dmaengine.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/dma/dmaengine.c +2 -0
index 6b535262ac5d..3db94e81bc14 100644
@@ -1107,12 +1107,14 @@ static struct dmaengine_unmap_pool *__get_unmap_pool(int nr)
 	switch (order) {
 	case 0 ... 1:
 		return &unmap_pool[0];
+#if IS_ENABLED(CONFIG_DMA_ENGINE_RAID)
 	case 2 ... 4:
 		return &unmap_pool[1];
 	case 5 ... 7:
 		return &unmap_pool[2];
 	case 8:
 		return &unmap_pool[3];
+#endif
 	default:
 		BUG();
 		return NULL;
Signature · 1 line
2.12.0.246.ga2ecc84866-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Matthias Kaehlcke

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]

Quoted 6 lines
                return &unmap_pool[3];
                        ^          ~

drivers/dma/dmaengine.c:1083:1: note: array 'unmap_pool' declared here static struct dmaengine_unmap_pool unmap_pool[] = {

Applied
#2 lore raw
In reply to Matthias Kaehlcke
Quoted 6 lines · Matthias Kaehlcke

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];
                        ^          ~
Quoted 8 lines

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[] = {

Applied, thanks

Signature · 1 line
~Vinod