]> git.baikalelectronics.ru Git - kernel.git/commit
Bluetooth: hidp: Fix module reference cleanup
authorDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 1 Nov 2011 16:27:50 +0000 (17:27 +0100)
committerGustavo F. Padovan <padovan@profusion.mobi>
Mon, 7 Nov 2011 19:24:54 +0000 (17:24 -0200)
commitc6d39f0be408c60e977692aa33d6331fb7c4193e
tree090ca61b8fbe3f97e4f5549ebe444ea5ea8fa728
parent6264c18bf0e4c66009f80001df5fc07e20f3f2bd
Bluetooth: hidp: Fix module reference cleanup

Calling module_put(THIS_MODULE) is *never* safe when we cannot go sure that we
own at least two references. This is because the call may unload our module
before it returns and then the "return" will jump into invalid memory.

Gladly, module.h provides a wrapper for kthread-users: module_put_and_exit().
This puts our module and then exits the kthread without returning to the module.

This patch fixes the hidp kthread to use this wrapper instead of manually
freeing its own reference. See nfsd or lockd for other kthreads using this.

Calling __module_get() inside the kthread is safe as the hidp module will always
wait until the kthread sets "waiting_for_startup" to 0.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
net/bluetooth/hidp/core.c