diff mbox series

wifi: cw1200: Fix potential NULL dereference

Message ID 20241217-cw1200-fix-v1-1-911e6b5823ec@linaro.org (mailing list archive)
State New
Delegated to: Kalle Valo
Headers show
Series wifi: cw1200: Fix potential NULL dereference | expand

Commit Message

Linus Walleij Dec. 17, 2024, 12:55 p.m. UTC
A recent refactoring was identified by static analysis to
cause another potential NULL dereference, fix this!

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202411271742.Xa7CNVh1-lkp@intel.com/
Fixes: 2719a9e7156c ("wifi: cw1200: Convert to GPIO descriptors")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/wireless/st/cw1200/cw1200_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
change-id: 20241217-cw1200-fix-d6a722f1e68f

Best regards,

Comments

Kalle Valo Dec. 17, 2024, 2:31 p.m. UTC | #1
Linus Walleij <linus.walleij@linaro.org> writes:

> A recent refactoring was identified by static analysis to
> cause another potential NULL dereference, fix this!
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202411271742.Xa7CNVh1-lkp@intel.com/
> Fixes: 2719a9e7156c ("wifi: cw1200: Convert to GPIO descriptors")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

If it's ok for you, I'll add the smatch warning to the commit message:

drivers/net/wireless/st/cw1200/cw1200_spi.c:440 cw1200_spi_disconnect() error: we previously assumed 'self' could be null (see line 433)
Linus Walleij Dec. 17, 2024, 2:49 p.m. UTC | #2
On Tue, Dec 17, 2024 at 3:31 PM Kalle Valo <kvalo@kernel.org> wrote:

> Linus Walleij <linus.walleij@linaro.org> writes:
>
> > A recent refactoring was identified by static analysis to
> > cause another potential NULL dereference, fix this!
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > Closes: https://lore.kernel.org/r/202411271742.Xa7CNVh1-lkp@intel.com/
> > Fixes: 2719a9e7156c ("wifi: cw1200: Convert to GPIO descriptors")
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> If it's ok for you, I'll add the smatch warning to the commit message:
>
> drivers/net/wireless/st/cw1200/cw1200_spi.c:440 cw1200_spi_disconnect() error: we previously assumed 'self' could be null (see line 433)

Sure go ahead!

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/net/wireless/st/cw1200/cw1200_spi.c b/drivers/net/wireless/st/cw1200/cw1200_spi.c
index 862964a8cc8761bb412b15addef562d61811440b..52386dfb5f4aa9c1f3e12e2a4002241d9ece72ee 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_spi.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_spi.c
@@ -442,8 +442,8 @@  static void cw1200_spi_disconnect(struct spi_device *func)
 			cw1200_core_release(self->core);
 			self->core = NULL;
 		}
+		cw1200_spi_off(self, dev_get_platdata(&func->dev));
 	}
-	cw1200_spi_off(self, dev_get_platdata(&func->dev));
 }
 
 static int __maybe_unused cw1200_spi_suspend(struct device *dev)