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

Bluetooth: Fix crash in the Marvell driver initialization codepath

btmrvl_add_card() function calls kthread_run that might return error
(e.g. if current thread is killed). If one tries to use the error
value as a pointer then invalid memory access oops happens.

Check kthread_run() return value, if it is an error then release resources
correctly.

TEST=boot computer with BT modules enabled. I see the error message that
BT device initialization failed. Now kernel does not crash. Hint: to enable
BT run 'rmmod btmrvl_sdio; modprobe btmrvl_sdio'

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Anatol Pomozov and committed by
Marcel Holtmann
8500d791 82c295b1

+5
+5
drivers/bluetooth/btmrvl_main.c
··· 710 710 init_waitqueue_head(&priv->main_thread.wait_q); 711 711 priv->main_thread.task = kthread_run(btmrvl_service_main_thread, 712 712 &priv->main_thread, "btmrvl_main_service"); 713 + if (IS_ERR(priv->main_thread.task)) 714 + goto err_thread; 713 715 714 716 priv->btmrvl_dev.card = card; 715 717 priv->btmrvl_dev.tx_dnld_rdy = true; 716 718 717 719 return priv; 720 + 721 + err_thread: 722 + btmrvl_free_adapter(priv); 718 723 719 724 err_adapter: 720 725 kfree(priv);