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>