]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: host: max3421-hcd: Fix error pointer dereference in probe cleanup
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 7 Aug 2025 15:55:00 +0000 (18:55 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Oct 2025 09:56:30 +0000 (11:56 +0200)
[ Upstream commit 186e8f2bdba551f3ae23396caccd452d985c23e3 ]

The kthread_run() function returns error pointers so the
max3421_hcd->spi_thread pointer can be either error pointers or NULL.
Check for both before dereferencing it.

Fixes: 05dfa5c9bc37 ("usb: host: max3421-hcd: fix "spi_rd8" uses dynamic stack allocation warning")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/aJTMVAPtRe5H6jug@stanley.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/host/max3421-hcd.c

index 8aaafba058aa9618d11818971494a08da1fd28fd..f170741206e1dfa60432eef812b86695fdee45bb 100644 (file)
@@ -1925,7 +1925,7 @@ error:
        if (hcd) {
                kfree(max3421_hcd->tx);
                kfree(max3421_hcd->rx);
-               if (max3421_hcd->spi_thread)
+               if (!IS_ERR_OR_NULL(max3421_hcd->spi_thread))
                        kthread_stop(max3421_hcd->spi_thread);
                usb_put_hcd(hcd);
        }