diff mbox series

[2/5] zfs: Add a comment to clarify nvlist memory layout

Message ID 20240407014743.13872-3-mwleeds@mailtundra.com
State Accepted
Delegated to: Tom Rini
Headers show
Series zfs: Fix zfs support on aarch64 | expand

Commit Message

mwleeds@mailtundra.com April 7, 2024, 1:47 a.m. UTC
Signed-off-by: Phaedrus Leeds <mwleeds@mailtundra.com>
Tested-by: Phaedrus Leeds <mwleeds@mailtundra.com>
---
 fs/zfs/zfs.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

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