Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0468a2cf authored by Jeff Layton's avatar Jeff Layton Committed by Steve French
Browse files

cifs: take module reference when starting cifsd



cifsd can outlive the last cifs mount. We need to hold a module
reference until it exits to prevent someone from unplugging
the module until we're ready.

Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 80909022
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -776,7 +776,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
		set_current_state(TASK_RUNNING);
	}

	return 0;
	module_put_and_exit(0);
}

/* extract the host portion of the UNC string */
@@ -2176,10 +2176,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
			so no need to spinlock this init of tcpStatus */
			srvTcp->tcpStatus = CifsNew;
			init_MUTEX(&srvTcp->tcpSem);

			/*
			 * since we're in a cifs function already, we know that
			 * this will succeed. No need for try_module_get().
			 */
			__module_get(THIS_MODULE);
			srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd");
			if (IS_ERR(srvTcp->tsk)) {
				rc = PTR_ERR(srvTcp->tsk);
				cERROR(1, ("error %d create cifsd thread", rc));
				module_put(THIS_MODULE);
				srvTcp->tsk = NULL;
				sock_release(csocket);
				kfree(srvTcp->hostname);