nvme: fix some memory leak bugs
PATCH 1/1 nvme: fix some memory leak bugs
Signed-off-by Ruozhu Li <[email protected]>
--- nvme-print.c | 6 +++++- nvme-rpmb.c | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-)
nvme-print.c +5 -1
@@ -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 *devicesreturn ; 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);
nvme-rpmb.c +4 -1
@@ -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 */
Signature · 7 lines
2.25.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme