Skip to content

Commit

Permalink
Bluetooth: Fix crash in the Marvell driver initialization codepath
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
  • Loading branch information
anatol authored and holtmann committed Jul 30, 2014
1 parent 82c295b commit 8500d79
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/bluetooth/btmrvl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,17 @@ struct btmrvl_private *btmrvl_add_card(void *card)
init_waitqueue_head(&priv->main_thread.wait_q);
priv->main_thread.task = kthread_run(btmrvl_service_main_thread,
&priv->main_thread, "btmrvl_main_service");
if (IS_ERR(priv->main_thread.task))
goto err_thread;

priv->btmrvl_dev.card = card;
priv->btmrvl_dev.tx_dnld_rdy = true;

return priv;

err_thread:
btmrvl_free_adapter(priv);

err_adapter:
kfree(priv);

Expand Down

0 comments on commit 8500d79

Please sign in to comment.