Commit 79f3068b authored by Suman Anna's avatar Suman Anna Committed by Hari Kanigeri

SYSLINK: ipc - decrement reference count properly.

This patch fixes the WARN_ON issue with the nameserver_destroy
function due to incorrect maintainance of the module state
reference count. This patch also includes minor code cleanup
changes.
Signed-off-by: default avatarSuman Anna <s-anna@ti.com>
parent 8cd35fef
...@@ -239,7 +239,7 @@ int nameserver_setup(void) ...@@ -239,7 +239,7 @@ int nameserver_setup(void)
if (atomic_inc_return(&nameserver_state.ref_count) if (atomic_inc_return(&nameserver_state.ref_count)
!= NAMESERVER_MAKE_MAGICSTAMP(1)) { != NAMESERVER_MAKE_MAGICSTAMP(1)) {
retval = -EEXIST; retval = -EEXIST;
goto error; goto exit;
} }
nr_procs = multiproc_get_max_processors(); nr_procs = multiproc_get_max_processors();
...@@ -265,6 +265,7 @@ int nameserver_setup(void) ...@@ -265,6 +265,7 @@ int nameserver_setup(void)
error: error:
kfree(list); kfree(list);
printk(KERN_ERR "nameserver_setup failed, retval: %x\n", retval); printk(KERN_ERR "nameserver_setup failed, retval: %x\n", retval);
exit:
return retval; return retval;
} }
EXPORT_SYMBOL(nameserver_setup); EXPORT_SYMBOL(nameserver_setup);
...@@ -284,7 +285,7 @@ int nameserver_destroy(void) ...@@ -284,7 +285,7 @@ int nameserver_destroy(void)
NAMESERVER_MAKE_MAGICSTAMP(1)) == true)) { NAMESERVER_MAKE_MAGICSTAMP(1)) == true)) {
retval = -ENODEV; retval = -ENODEV;
goto exit; goto exit;
} }
if (WARN_ON(nameserver_state.list_lock == NULL)) { if (WARN_ON(nameserver_state.list_lock == NULL)) {
retval = -ENODEV; retval = -ENODEV;
...@@ -297,6 +298,12 @@ int nameserver_destroy(void) ...@@ -297,6 +298,12 @@ int nameserver_destroy(void)
goto exit; goto exit;
} }
if (!(atomic_dec_return(&nameserver_state.ref_count)
== NAMESERVER_MAKE_MAGICSTAMP(0))) {
retval = -EBUSY;
goto exit;
}
retval = mutex_lock_interruptible(nameserver_state.list_lock); retval = mutex_lock_interruptible(nameserver_state.list_lock);
if (retval) if (retval)
goto exit; goto exit;
......
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