[lvc-project] [PATCH] drivers: spi: deref after NULL check
    Alexandr Sapozhnikov 
    alsp705 at gmail.com
       
    Fri Jun  7 17:10:11 MSK 2024
    
    
  
After having been compared to a NULL value at spi.c:2821,
pointer 'ctlr' is dereferenced at spi.c:2840 and spi.c:2848.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Alexandr Sapozhnikov <alsp705 at gmail.com>
---
 drivers/spi/spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 9bc9fd10d538..d213dd1b2db5 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2818,7 +2818,7 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,
 	struct spi_device *spi;
 	int ret;
 
-	if (!ctlr && index == -1)
+	if (!ctlr || index == -1)
 		return ERR_PTR(-EINVAL);
 
 	lookup.ctlr		= ctlr;
-- 
2.39.2
    
    
More information about the lvc-project
mailing list