Signed-off-by: Phaedrus Leeds <mwle...@mailtundra.com>
Tested-by: Phaedrus Leeds <mwle...@mailtundra.com>
---
 fs/zfs/zfs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/zfs/zfs.c b/fs/zfs/zfs.c
index 14779dee32..61d58fce68 100644
--- a/fs/zfs/zfs.c
+++ b/fs/zfs/zfs.c
@@ -1610,20 +1610,25 @@ zfs_nvlist_lookup_nvlist(char *nvlist, char *name)
 {
        char *nvpair;
        char *ret;
        size_t size;
        int found;
 
        found = nvlist_find_value(nvlist, name, DATA_TYPE_NVLIST, &nvpair,
                                                          &size, 0);
        if (!found)
                return 0;
+
+       /* Allocate 12 bytes in addition to the nvlist size: One uint32 before 
the
+        * nvlist to hold the encoding method, and two zero uint32's after the
+        * nvlist as the NULL terminator.
+        */
        ret = calloc(1, size + 3 * sizeof(uint32_t));
        if (!ret)
                return 0;
        memcpy(ret, nvlist, sizeof(uint32_t));
 
        memcpy(ret + sizeof(uint32_t), nvpair, size);
        return ret;
 }
 
 int
-- 
2.44.0

Reply via email to