* [PATCH] dma-engine: Fix array index out of bounds warning in __get_unmap_pool()
@ 2017-03-13 21:30 Matthias Kaehlcke
2017-03-13 21:52 ` Dan Williams
2017-03-14 4:43 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Matthias Kaehlcke @ 2017-03-13 21:30 UTC (permalink / raw)
To: Vinod Koul, Dan Williams
Cc: dmaengine, linux-kernel, Grant Grundler, 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]
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>
---
drivers/dma/dmaengine.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 6b535262ac5d..3db94e81bc14 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -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;
--
2.12.0.246.ga2ecc84866-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dma-engine: Fix array index out of bounds warning in __get_unmap_pool()
2017-03-13 21:30 [PATCH] dma-engine: Fix array index out of bounds warning in __get_unmap_pool() Matthias Kaehlcke
@ 2017-03-13 21:52 ` Dan Williams
2017-03-14 4:43 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2017-03-13 21:52 UTC (permalink / raw)
To: Matthias Kaehlcke
Cc: Vinod Koul, dmaengine@vger.kernel.org,
linux-kernel@vger.kernel.org, Grant Grundler
On Mon, Mar 13, 2017 at 2:30 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
> 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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dma-engine: Fix array index out of bounds warning in __get_unmap_pool()
2017-03-13 21:30 [PATCH] dma-engine: Fix array index out of bounds warning in __get_unmap_pool() Matthias Kaehlcke
2017-03-13 21:52 ` Dan Williams
@ 2017-03-14 4:43 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2017-03-14 4:43 UTC (permalink / raw)
To: Matthias Kaehlcke; +Cc: Dan Williams, dmaengine, linux-kernel, Grant Grundler
On Mon, Mar 13, 2017 at 02:30:29PM -0700, Matthias Kaehlcke wrote:
> 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[] = {
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-14 4:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-13 21:30 [PATCH] dma-engine: Fix array index out of bounds warning in __get_unmap_pool() Matthias Kaehlcke
2017-03-13 21:52 ` Dan Williams
2017-03-14 4:43 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).