All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nvme-cli] nvme: fix some memory leak bugs
@ 2021-07-16  6:10 Ruozhu Li
  0 siblings, 0 replies; only message in thread
From: Ruozhu Li @ 2021-07-16  6:10 UTC (permalink / raw)
  To: kbusch, linux-nvme; +Cc: jiangtao62

Signed-off-by: Ruozhu Li <liruozhu@huawei.com>
---
 nvme-print.c | 6 +++++-
 nvme-rpmb.c  | 5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/nvme-print.c b/nvme-print.c
index 9444154..e808851 100755
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -2618,6 +2618,8 @@ void nvme_show_relatives(const char *name)
 			comma = true;
 		}
 		fprintf(stderr, "\n\n");
+		for (i = 0; i < n; i++)
+			free(paths[i]);
 		free(paths);
 	}
 	free(path);
@@ -6382,8 +6384,10 @@ static void json_simple_ns(struct nvme_namespace *n, struct json_object *devices
 		return;
 
 	ret = stat(devnode, &st);
-	if (ret < 0)
+	if (ret < 0) {
+		free(devnode);
 		return;
+	}
 
 	device_attrs = json_create_object();
 	json_object_add_value_int(device_attrs, "NameSpace", n->nsid);
diff --git a/nvme-rpmb.c b/nvme-rpmb.c
index 0e11ef3..7dc0b58 100644
--- a/nvme-rpmb.c
+++ b/nvme-rpmb.c
@@ -278,7 +278,10 @@ static void rpmb_nonce_init(struct rpmb_data_frame_t *req)
 {
 	int num = rand();
 	unsigned char *hash = rpmb_md5((unsigned char *)&num, sizeof(num));
-	if (hash) memcpy(req->nonce, hash, sizeof(req->nonce));
+	if (hash) {
+		memcpy(req->nonce, hash, sizeof(req->nonce));
+		free(hash);
+	}
 }
 
 /* Read key from a given key buffer or key file */
-- 
2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-16  6:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16  6:10 [PATCH nvme-cli] nvme: fix some memory leak bugs Ruozhu Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.