Author: hselasky
Date: Tue Jul 17 08:54:40 2018
New Revision: 336366
URL: https://svnweb.freebsd.org/changeset/base/336366

Log:
  If the MGID/MLID pair is not on the list return an error in ibcore.
  
  A list of MGID/MLID pairs is built when doing a multicast attach.  When
  the multicast detach is called, the list is searched, and regardless of
  the search outcome, the driver detach is called.
  
  If an MGID/MLID pair is not on the list, driver detach should not be
  called, and an error should be returned.  Calling the driver without
  removing an MGID/MLID pair from the list can leave the core and driver
  out of sync.
  
  Linux commit:
  20c7840a77ddcb2ed2fbd66e8197db2868495751
  
  MFC after:            1 week
  Sponsored by:         Mellanox Technologies

Modified:
  head/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c

Modified: head/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c       Tue Jul 17 
08:52:29 2018        (r336365)
+++ head/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c       Tue Jul 17 
08:54:40 2018        (r336366)
@@ -3071,6 +3071,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *
        struct ib_qp                 *qp;
        struct ib_uverbs_mcast_entry *mcast;
        int                           ret = -EINVAL;
+       bool                          found = false;
 
        if (copy_from_user(&cmd, buf, sizeof cmd))
                return -EFAULT;
@@ -3082,17 +3083,21 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *
        obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
        mutex_lock(&obj->mcast_lock);
 
-       ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
-       if (ret)
-               goto out_put;
-
        list_for_each_entry(mcast, &obj->mcast_list, list)
                if (cmd.mlid == mcast->lid &&
                    !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
                        list_del(&mcast->list);
                        kfree(mcast);
+                       found = true;
                        break;
                }
+
+       if (!found) {
+               ret = -EINVAL;
+               goto out_put;
+       }
+
+       ret = ib_detach_mcast(qp, (union ib_gid *)cmd.gid, cmd.mlid);
 
 out_put:
        mutex_unlock(&obj->mcast_lock);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to