From a69cd7a6576930f762735b309fe6c0d4c428686c Mon Sep 17 00:00:00 2001 From: Low-power Date: Thu, 21 Apr 2022 04:35:44 +0800 Subject: [PATCH] zpool_history_unpack: return correct errno on nvlist_unpack failure Reviewed-by: Brian Behlendorf Reviewed-by: Damian Szuberski Signed-off-by: WHR Closes #13321 --- lib/libzutil/zutil_pool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libzutil/zutil_pool.c b/lib/libzutil/zutil_pool.c index 734650f3cffc..21dc1f9d9458 100644 --- a/lib/libzutil/zutil_pool.c +++ b/lib/libzutil/zutil_pool.c @@ -120,8 +120,9 @@ zpool_history_unpack(char *buf, uint64_t bytes_read, uint64_t *leftover, break; /* unpack record */ - if (nvlist_unpack(buf + sizeof (reclen), reclen, &nv, 0) != 0) - return (ENOMEM); + int err = nvlist_unpack(buf + sizeof (reclen), reclen, &nv, 0); + if (err != 0) + return (err); bytes_read -= sizeof (reclen) + reclen; buf += sizeof (reclen) + reclen;