Thread (6 messages) flat view 6 messages, 3 authors, 2011-11-01

Re: [PATCH] Bluetooth: hidp: Fix module reference cleanup

From: Gustavo Padovan <hidden>
Date: 2011-11-01 17:25:11

Hi David,

* David Herrmann [off-list ref] [2011-11-01 17:27:50 +0100]:
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 <redacted>
---
V3: I rebased on top of bluetooth-next plus the patches already pending on the
ML. It should apply cleanly now. Otherwise, just tell me what tree to use for
the rebase ;) Or try "git am -3 ..."

 net/bluetooth/hidp/core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.

	Gustavo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help