From 18118fdab50ea0041d3d4c99b07e0ee6d4ec43d1 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sun, 4 Feb 2024 22:55:05 +0900 Subject: [PATCH] nvme: Reduce get-reg command memory allocation size Reduce the size to the register offset to get. Signed-off-by: Tokunori Ikegami --- nvme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nvme.c b/nvme.c index d0ee2db1c4..10658cdf36 100644 --- a/nvme.c +++ b/nvme.c @@ -5410,7 +5410,8 @@ bool nvme_is_fabrics_reg(int offset) static int get_register_property(int fd, void **pbar, int offset) { - int err, size = getpagesize(); + int err; + int size = offset + 1 + nvme_is_64bit_reg(offset) ? sizeof(uint64_t) : sizeof(uint32_t); __u64 value; void *bar = malloc(size); struct nvme_get_property_args args = {