domain: add BUG_ON()
authorKay Sievers <kay@vrfy.org>
Thu, 31 Jul 2014 14:59:27 +0000 (16:59 +0200)
committerKay Sievers <kay@vrfy.org>
Thu, 31 Jul 2014 14:59:27 +0000 (16:59 +0200)
domain.c
handle.c

index eeb73ca7e5639af827e81724207dc21040dfd87d..6f6df158699551d247cb1b818b36c0d0e36e3207 100644 (file)
--- a/domain.c
+++ b/domain.c
@@ -462,15 +462,10 @@ static int kdbus_domain_user_assign_id(struct kdbus_domain *domain,
  *
  * Return: 0 on success, negative errno on failure.
  *
- * On success: if there is a uid matching, then use the already
- * accounted kdbus_domain_user, increment its reference counter and
- * return it in the 'user' argument. Otherwise, allocate a new one,
- * link it into the domain, then return it.
- *
- * On failure: the 'user' argument is not updated.
- *
- * Caller must have the domain lock held and must ensure that the
- * domain was not disconnected.
+ * If there is a uid matching, then use the already accounted
+ * kdbus_domain_user, increment its reference counter and
+ * return it in the @user argument. Otherwise allocate a new one,
+ * link it into the domain and return it.
  */
 int __kdbus_domain_user_account(struct kdbus_domain *domain,
                                kuid_t uid,
@@ -480,6 +475,8 @@ int __kdbus_domain_user_account(struct kdbus_domain *domain,
        struct kdbus_domain_user *tmp_user;
        struct kdbus_domain_user *u = NULL;
 
+       BUG_ON(!mutex_is_locked(&domain->lock));
+
        /* find uid and reference it */
        if (uid_valid(uid)) {
                hash_for_each_possible(domain->user_hash, tmp_user,
index d8e1dc62b8abeb9cc4bf8f9dbc934ad27607b5f5..59842c15c0daaeee156cc74e2964f76a69755c77 100644 (file)
--- a/handle.c
+++ b/handle.c
@@ -464,9 +464,8 @@ static long kdbus_handle_ioctl_ep(struct file *file, unsigned int cmd,
                 * endpoint users do not share the budget with the ordinary
                 * users created for a UID.
                 */
-               ret = kdbus_domain_user_account(
-                               handle->ep->bus->domain,
-                               INVALID_UID, &ep->user);
+               ret = kdbus_domain_user_account(handle->ep->bus->domain,
+                                               INVALID_UID, &ep->user);
                if (ret < 0) {
                        kdbus_ep_unref(ep);
                        break;