summaryrefslogtreecommitdiff
path: root/domain.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-09-29 19:42:28 +0200
committerroot <root@tomegun-x240.getinternet.no>2014-09-29 21:01:45 +0200
commitc2cff7272ee084ad7f429a84b2242f363d63fda9 (patch)
tree0da04234183e1c512741b5c29162e2c601c267f2 /domain.c
parent78fb6cd8736845ea0ac811e069b029a33515adb5 (diff)
downloadkdbus-bus-c2cff7272ee084ad7f429a84b2242f363d63fda9.tar.gz
kdbus-bus-c2cff7272ee084ad7f429a84b2242f363d63fda9.tar.bz2
kdbus-bus-c2cff7272ee084ad7f429a84b2242f363d63fda9.zip
domain: slightly simplify kdbus_domain_new()
No need to lock the kstrdup() call. This also merges two conditionals.
Diffstat (limited to 'domain.c')
-rw-r--r--domain.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/domain.c b/domain.c
index 06c10684332..06d9c228acf 100644
--- a/domain.c
+++ b/domain.c
@@ -261,29 +261,30 @@ int kdbus_domain_new(struct kdbus_domain *parent, const char *name,
atomic64_set(&d->msg_seq_last, 0);
idr_init(&d->user_idr);
- /* lock order: parent domain -> domain -> subsys_lock */
- if (parent) {
- mutex_lock(&parent->lock);
- if (parent->disconnected) {
- mutex_unlock(&parent->lock);
- ret = -ESHUTDOWN;
- goto exit_free;
- }
- }
-
- mutex_lock(&kdbus_subsys_lock);
-
/* compose name and path of base directory in /dev */
if (!parent) {
/* initial domain */
d->devpath = kstrdup(KBUILD_MODNAME, GFP_KERNEL);
if (!d->devpath) {
ret = -ENOMEM;
- goto exit_unlock;
+ goto exit_free;
}
+
+ mutex_lock(&kdbus_subsys_lock);
+
} else {
struct kdbus_domain *exists;
+ /* lock order: parent domain -> domain -> subsys_lock */
+ mutex_lock(&parent->lock);
+ if (parent->disconnected) {
+ mutex_unlock(&parent->lock);
+ ret = -ESHUTDOWN;
+ goto exit_free;
+ }
+
+ mutex_lock(&kdbus_subsys_lock);
+
exists = kdbus_domain_find(parent, name);
if (exists) {
kdbus_domain_unref(exists);