> @@ -1910,12 +1911,15 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file
> *file,
> 
>       obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
> 
> +     spin_lock(&qp->mcast_lock);
>       list_for_each_entry(mcast, &obj->mcast_list, list)
>               if (cmd.mlid == mcast->lid &&
>                   !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
>                       ret = 0;
> +                     spin_unlock(&qp->mcast_lock);
>                       goto out_put;
>               }
> +     spin_unlock(&qp->mcast_lock);

Does the lower level code protect against trying to join the same group twice?  
The locking ends up looking racy here, with the lock being dropped between 
checking the list and adding the new entry.

> @@ -1961,6 +1968,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file
> *file,
> 
>       obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
> 
> +     spin_lock(&qp->mcast_lock);
>       list_for_each_entry(mcast, &obj->mcast_list, list)
>               if (cmd.mlid == mcast->lid &&
>                   !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
> @@ -1968,6 +1976,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file
> *file,
>                       kfree(mcast);
>                       break;
>               }
> +     spin_unlock(&qp->mcast_lock);

I wonder if the uverbs code should prevent the user from trying to join a group 
twice and prevent it from leaving a group that it hasn't joined.  This is a 
separate question from these patches, but it would affect how the locking is 
held. 

- Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to