Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: host: max3421-hcd: Fix error pointer dereference in probe cleanup

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>

authored by

Dan Carpenter and committed by
Greg Kroah-Hartman
186e8f2b aeb01692

+1 -1
+1 -1
drivers/usb/host/max3421-hcd.c
··· 1916 1916 if (hcd) { 1917 1917 kfree(max3421_hcd->tx); 1918 1918 kfree(max3421_hcd->rx); 1919 - if (max3421_hcd->spi_thread) 1919 + if (!IS_ERR_OR_NULL(max3421_hcd->spi_thread)) 1920 1920 kthread_stop(max3421_hcd->spi_thread); 1921 1921 usb_put_hcd(hcd); 1922 1922 }