Whamcloud - gitweb
LU-9679 lnet: tidy lnet_discover and fix mem accounting bug. 44/38644/3
authorMr NeilBrown <neilb@suse.de>
Sun, 17 May 2020 23:21:27 +0000 (09:21 +1000)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 May 2020 05:04:08 +0000 (05:04 +0000)
commit45722de60a8fb5fee86a07ce5e3861b31dcedf59
tree06820e04a11f97a1f5ac34a6f5a6f1fc51510442
parentef9718e8e9cf8fb7f7dedf2ab7ee3f6ba1646108
LU-9679 lnet: tidy lnet_discover and fix mem accounting bug.

A recent patch introduce a memory accounting bug because "n_ids"
can change between the ALLOC call and the FREE call.

With this patch we fix that by ensuring n_ids doesn't change - the
current change is not needed.
Also:
 - discard 'max_intf' var.  It is always exactly lnet_interfaces_max,
   so just use that directly.
 - only copy back the number of interfaces found
 - report the number of interfaces actually copied.
 - Move the copy_to_user until after all locks and references are
   dropped so there is no need to re-take any locks.

Test-Parameters: trivial
Fixes: b1f6f3becedc ("LU-9679 libcfs: Add CFS_ALLOC_PTR_ARRAY and free")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Ib807ca4ce5235b28e7ae11d90e1942aff4454cfc
Reviewed-on: https://review.whamcloud.com/38644
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/api-ni.c