zpool_history_unpack: return correct errno on nvlist_unpack failure

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: WHR <msl0000023508@gmail.com>
Closes #13321
This commit is contained in:
Low-power 2022-04-21 04:35:44 +08:00 committed by GitHub
parent 9b80d9e6f9
commit 115a92ca6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;