*
* 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,
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,
* 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;