Commit f1b6caac authored by Marcel Holtmann's avatar Marcel Holtmann

[Bluetooth] Use try_module_get() for RFCOMM sessions

It is not possible to use __module_get() when adding a new RFCOMM
session, because there is a case where no reference count is hold.
This happens when the module is not in use right now and an incoming
connection occurs.
parent 9ea9778e
...@@ -480,15 +480,16 @@ struct rfcomm_session *rfcomm_session_add(struct socket *sock, int state) ...@@ -480,15 +480,16 @@ struct rfcomm_session *rfcomm_session_add(struct socket *sock, int state)
s->mtu = RFCOMM_DEFAULT_MTU; s->mtu = RFCOMM_DEFAULT_MTU;
s->cfc = RFCOMM_CFC_UNKNOWN; s->cfc = RFCOMM_CFC_UNKNOWN;
/* Do not increment module usage count for listening sessions.
* Otherwise we won't be able to unload the module. */
if (state != BT_LISTEN)
if (!try_module_get(THIS_MODULE)) {
kfree(s);
return NULL;
}
list_add(&s->list, &session_list); list_add(&s->list, &session_list);
/* Do not increment module usage count for listeting sessions.
* Otherwise we won't be able to unload the module.
* Non listening session are added either by a socket or a TTYs
* which means that we already hold refcount to this module.
*/
if (state != BT_LISTEN)
__module_get(THIS_MODULE);
return s; return s;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment