linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: stm32: fix NULL check on pointer-to-pointer variable
@ 2025-06-28  0:02 Antonio Quartulli
  2025-06-30  7:34 ` Clement LE GOFFIC
  0 siblings, 1 reply; 10+ messages in thread
From: Antonio Quartulli @ 2025-06-28  0:02 UTC (permalink / raw)
  To: linux-spi
  Cc: linux-stm32, linux-arm-kernel, linux-kernel,
	Clément Le Goffic, Alexandre Torgue, Maxime Coquelin,
	Mark Brown, Alain Volmat, Antonio Quartulli

In stm32_spi_prepare_rx_dma_mdma_chaining() both rx_dma_desc
and rx_mdma_desc are passed as pointer-to-pointer arguments.

The goal is to pass back to the caller the value returned
by dmaengine_prep_slave_sg(), when it is not NULL.

However, the NULL check on the result is erroneously
performed without dereferencing the pointer.

Add the proper dereference operator to both checks.

Fixes: d17dd2f1d8a1 ("spi: stm32: use STM32 DMA with STM32 MDMA to enhance DDR use")
Addresses-Coverity-ID: 1644715 ("Null pointer dereferences (REVERSE_INULL)")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
 drivers/spi/spi-stm32.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 3d20f09f1ae7..e9fa17e52fb0 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1529,7 +1529,7 @@ static int stm32_spi_prepare_rx_dma_mdma_chaining(struct stm32_spi *spi,
 					       DMA_PREP_INTERRUPT);
 	sg_free_table(&dma_sgt);
 
-	if (!rx_dma_desc)
+	if (!*rx_dma_desc)
 		return -EINVAL;
 
 	/* Prepare MDMA slave_sg transfer MEM_TO_MEM (SRAM>DDR) */
@@ -1563,8 +1563,8 @@ static int stm32_spi_prepare_rx_dma_mdma_chaining(struct stm32_spi *spi,
 						DMA_PREP_INTERRUPT);
 	sg_free_table(&mdma_sgt);
 
-	if (!rx_mdma_desc) {
-		rx_dma_desc = NULL;
+	if (!*rx_mdma_desc) {
+		*rx_dma_desc = NULL;
 		return -EINVAL;
 	}
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-07-01 22:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-28  0:02 [PATCH] spi: stm32: fix NULL check on pointer-to-pointer variable Antonio Quartulli
2025-06-30  7:34 ` Clement LE GOFFIC
2025-06-30  7:48   ` Antonio Quartulli
2025-06-30  8:12   ` [PATCH v2] spi: stm32: fix pointer-to-pointer variables usage Antonio Quartulli
2025-06-30  8:28     ` Clement LE GOFFIC
2025-06-30 11:20       ` Mark Brown
2025-06-30 12:00         ` Clement LE GOFFIC
2025-06-30 11:40     ` Alain Volmat
2025-06-30 11:58     ` Clement LE GOFFIC
2025-07-01 22:15     ` Mark Brown

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).