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

Jiajun Chen posted 1 patch 6 years, 1 month ago
Test asan failed
Test checkpatch failed
Test FreeBSD failed
Test docker-mingw@fedora failed
Test docker-clang@ubuntu failed
Test docker-quick@centos7 failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20191220094934.21232-1-chenjiajun8@huawei.com
Maintainers: Greg Kurz <groug@kaod.org>
hw/9pfs/9p-local.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] 9pfs: local: Fix possible memory leak in local_link()
Posted by Jiajun Chen 6 years, 1 month ago
There is a possible memory leak while local_link return -1 without free
odirpath and oname.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Jaijun Chen <chenjiajun8@huawei.com>
Signed-off-by: Xiang Zheng <zhengxiang9@huawei.com>
---
 hw/9pfs/9p-local.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 4708c0bd89..491b08aee8 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -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);
-- 
2.21.0.windows.1



Re: [PATCH] 9pfs: local: Fix possible memory leak in local_link()
Posted by Greg Kurz 6 years, 1 month ago
On Fri, 20 Dec 2019 17:49:34 +0800
Jiajun Chen <chenjiajun8@huawei.com> wrote:

> There is a possible memory leak while local_link return -1 without free
> odirpath and oname.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Jaijun Chen <chenjiajun8@huawei.com>
> Signed-off-by: Xiang Zheng <zhengxiang9@huawei.com>
> ---

Applied to 9p-next.

Thanks.

>  hw/9pfs/9p-local.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index 4708c0bd89..491b08aee8 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -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);


Re: [PATCH] 9pfs: local: Fix possible memory leak in local_link()
Posted by Philippe Mathieu-Daudé 6 years, 1 month ago
On 12/23/19 11:59 AM, Greg Kurz wrote:
> On Fri, 20 Dec 2019 17:49:34 +0800
> Jiajun Chen <chenjiajun8@huawei.com> wrote:
> 
>> There is a possible memory leak while local_link return -1 without free
>> odirpath and oname.
>>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Jaijun Chen <chenjiajun8@huawei.com>
>> Signed-off-by: Xiang Zheng <zhengxiang9@huawei.com>
>> ---
> 
> Applied to 9p-next.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> 
> Thanks.
> 
>>   hw/9pfs/9p-local.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
>> index 4708c0bd89..491b08aee8 100644
>> --- a/hw/9pfs/9p-local.c
>> +++ b/hw/9pfs/9p-local.c
>> @@ -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);
> 
> 


Re: [PATCH] 9pfs: local: Fix possible memory leak in local_link()
Posted by Christian Schoenebeck 6 years, 1 month ago
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.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Jaijun Chen <chenjiajun8@huawei.com>
> Signed-off-by: Xiang Zheng <zhengxiang9@huawei.com>

Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>

> ---
>  hw/9pfs/9p-local.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index 4708c0bd89..491b08aee8 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -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);

Best regards,
Christian Schoenebeck