Skip to contentSkip to conversation

9pfs: local: Fix possible memory leak in local_link()

PATCH Applied Jiajun Chen 4 participants 4 messages Dec 20, 2019 – Jan 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 9pfs: local: Fix possible memory leak in local_link()

There is a possible memory leak while local_link return -1 without free odirpath and oname.

---
 hw/9pfs/9p-local.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p-local.c +1 -1
index 4708c0bd89..491b08aee8 100644
@@ -947,7 +947,7 @@ static int local_link(FsContext *ctx, V9fsPath *oldpath,
     if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&
         local_is_mapped_file_metadata(ctx, name)) {
         errno = EINVAL;
-        return -1;
+        goto out;
     }
 
     odirfd = local_opendir_nofollow(ctx, odirpath);
Signature · 1 line
2.21.0.windows.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Freitag, 20. Dezember 2019 10:49:34 CET Jiajun Chen wrote:

There is a possible memory leak while local_link return -1 without free odirpath and oname.

Quoted 12 lines
---
 hw/9pfs/9p-local.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p-local.c +0 -0
index 4708c0bd89..491b08aee8 100644
@@ -947,7 +947,7 @@ static int local_link(FsContext *ctx, V9fsPath *oldpath,

if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&

         local_is_mapped_file_metadata(ctx, name)) {
         errno = EINVAL;

hw/9pfs/9p-local.c static int local_link(FsContext *ctx, V9fsPath *oldpath, · line 953

Quoted 5 lines
hw/9pfs/9p-local.c +1 -1
-        return -1;
+        goto out;
     }
 
     odirfd = local_opendir_nofollow(ctx, odirpath);

Best regards,
Christian Schoenebeck

Applied
#2 lore raw
In reply to Jiajun Chen
Quoted 7 lines · On Fri, 20 Dec 2019 17:49:34 +0800 Jiajun Chen <[email protected]> wrote:

There is a possible memory leak while local_link return -1 without free odirpath and oname.

---

Applied to 9p-next.

Thanks.

Quoted 16 lines
 hw/9pfs/9p-local.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p-local.c +1 -1
index 4708c0bd89..491b08aee8 100644
@@ -947,7 +947,7 @@ static int local_link(FsContext *ctx, V9fsPath *oldpath,
     if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&
         local_is_mapped_file_metadata(ctx, name)) {
         errno = EINVAL;
-        return -1;
+        goto out;
     }
 
     odirfd = local_opendir_nofollow(ctx, odirpath);
#3 lore raw
Quoted 6 lines · Greg Kurz
Quoted 3 lines · On Fri, 20 Dec 2019 17:49:34 +0800 Jiajun Chen <[email protected]> wrote:

There is a possible memory leak while local_link return -1 without free odirpath and oname.

Quoted 6 lines
Quoted 4 lines

---

Applied to 9p-next.

Quoted 21 lines

Thanks.

Quoted 16 lines
  hw/9pfs/9p-local.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p-local.c +1 -1
index 4708c0bd89..491b08aee8 100644
@@ -947,7 +947,7 @@ static int local_link(FsContext *ctx, V9fsPath *oldpath,
      if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&
          local_is_mapped_file_metadata(ctx, name)) {
          errno = EINVAL;
-        return -1;
+        goto out;
      }
 
      odirfd = local_opendir_nofollow(ctx, odirpath);