]> git.baikalelectronics.ru Git - kernel.git/commit
dmaengine: dw-axi-dmac: Do not dereference NULL structure
authorKees Cook <keescook@chromium.org>
Fri, 27 Jan 2023 22:36:27 +0000 (14:36 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:39 +0000 (09:33 +0100)
commit6c2c0204f39510b656648f12a274cbc325aa17e1
treee41c75414032c1695fcf85673ee15539eb8b874d
parentcfa2521c694d0cab3aec8bfe3a27b168e62e7bed
dmaengine: dw-axi-dmac: Do not dereference NULL structure

[ Upstream commit 91141fcd0c9c555ddc38f5b43e05c5b420d8173e ]

If "vdesc" is NULL, it cannot be used with vd_to_axi_desc(). Leave
"bytes" unchanged at 0. Seen under GCC 13 with -Warray-bounds:

../drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c: In function 'dma_chan_tx_status':
../drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:329:46: warning: array subscript 0 is outside array bounds of 'struct
virt_dma_desc[46116860184273879]' [-Warray-bounds=]
  329 |                 bytes = vd_to_axi_desc(vdesc)->length;
      |                                              ^~

Fixes: 98d7cbf4ddfc ("dmaengine: dw-axi-dmac: Support burst residue granularity")
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230127223623.never.507-kees@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c