summaryrefslogtreecommitdiff
path: root/net/bluetooth/cmtp/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/cmtp/core.c')
-rw-r--r--net/bluetooth/cmtp/core.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 3a39fd523e40..b1757895c4ad 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -392,6 +392,11 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
if (!(session->flags & BIT(CMTP_LOOPBACK))) {
err = cmtp_attach_device(session);
if (err < 0) {
+ /* Caller will call fput in case of failure, and so
+ * will cmtp_session kthread.
+ */
+ get_file(session->sock->file);
+
atomic_inc(&session->terminate);
wake_up_interruptible(sk_sleep(session->sock->sk));
up_write(&cmtp_session_sem);