From 542685c3d70f08b2a24fa3594f35727c397f2ea9 Mon Sep 17 00:00:00 2001 From: Martin George Date: Sat, 14 Jun 2025 13:12:07 +0530 Subject: [PATCH] nvme: fix mem leak in nvme copy Valgrind revealed a mem leak in copy_cmd() due to the copy pointer not getting freed after usage. Fix the same. Signed-off-by: Martin George --- nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvme.c b/nvme.c index 5992335418..e52fc818f5 100644 --- a/nvme.c +++ b/nvme.c @@ -7446,12 +7446,12 @@ static int copy_cmd(int argc, char **argv, struct command *cmd, struct plugin *p __u32 elbatms[256] = { 0 }; __u32 elbats[256] = { 0 }; - union { + _cleanup_free_ union { struct nvme_copy_range f0[256]; struct nvme_copy_range_f1 f1[256]; struct nvme_copy_range_f2 f2[256]; struct nvme_copy_range_f3 f3[256]; - } *copy; + } *copy = NULL; struct config { __u32 namespace_id;