Fix use-after-free in btree code
Coverty static analysis found these.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #10989
Closes #13861
Approved by: so
Security: FreeBSD-EN-22:21.zfs
(cherry picked from commit 8131a96544fd19411c23424af85140e91e41c001)