From: Chengyu Zhu <hudson...@tencent.com>

The erofs_nbd_get_identifier() function returns dynamically allocated
memory via getline(), but the caller in erofsmount_nbd() was not
freeing this memory, causing a 120-byte memory leak.

Add proper memory cleanup by calling free(id) when the identifier
is not an error pointer.

Signed-off-by: Chengyu Zhu <hudson...@tencent.com>
---
 mount/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mount/main.c b/mount/main.c
index b22a729..c52ac3b 100644
--- a/mount/main.c
+++ b/mount/main.c
@@ -691,6 +691,8 @@ static int erofsmount_nbd(struct erofs_nbd_source *source,
                        if (err)
                                erofs_warn("failed to turn on autoclear for 
nbd%d: %s",
                                           num, erofs_strerror(err));
+                       if (!IS_ERR(id))
+                               free(id);
                }
        }
        return err;
-- 
2.51.0


Reply via email to