@@ -4163,7 +4163,6 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
int cpt;
int i;
int rc;
- int max_intf = lnet_interfaces_max;
if (n_ids <= 0 ||
id.nid == LNET_NID_ANY)
@@ -4172,11 +4171,11 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
if (id.pid == LNET_PID_ANY)
id.pid = LNET_PID_LUSTRE;
- /* if the user buffer has more space than the max_intf
- * then only fill it up to max_intf
+ /* If the user buffer has more space than the lnet_interfaces_max,
+ * then only fill it up to lnet_interfaces_max.
*/
- if (n_ids > max_intf)
- n_ids = max_intf;
+ if (n_ids > lnet_interfaces_max)
+ n_ids = lnet_interfaces_max;
buf = kcalloc(n_ids, sizeof(*buf), GFP_KERNEL);
if (!buf)
@@ -4204,11 +4203,6 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
if (rc)
goto out_decref;
- /* Peer may have changed. */
- lp = lpni->lpni_peer_net->lpn_peer;
- if (lp->lp_nnis < n_ids)
- n_ids = lp->lp_nnis;
-
i = 0;
p = NULL;
while ((p = lnet_get_next_peer_ni_locked(lp, NULL, p)) != NULL) {
@@ -4217,20 +4211,18 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
if (++i >= n_ids)
break;
}
+ rc = i;
- lnet_net_unlock(cpt);
-
- rc = -EFAULT;
- if (copy_to_user(ids, buf, n_ids * sizeof(*buf)))
- goto out_relock;
- rc = n_ids;
-out_relock:
- lnet_net_lock(cpt);
out_decref:
lnet_peer_ni_decref_locked(lpni);
out:
lnet_net_unlock(cpt);
+
+ if (rc >= 0)
+ if (copy_to_user(ids, buf, rc * sizeof(*buf)))
+ rc = -EFAULT;
kfree(buf);
+
return rc;
}