[Qemu-devel] [PATCH] pc-bios/s390-ccw/net: fix a possible memory leak in get_uuid()

luoyifan@cmss.chinamobile.com posted 1 patch 3 days ago
Test s390x failed
Test docker-mingw@fedora passed
Test asan passed
Test FreeBSD passed
Test docker-clang@ubuntu passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/02cf01d55267$86cf2850$946d78f0$@cmss.chinamobile.com
Maintainers: Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>, Christian Borntraeger <borntraeger@de.ibm.com>
pc-bios/s390-ccw/netmain.c | 1 +
1 file changed, 1 insertion(+)

[Qemu-devel] [PATCH] pc-bios/s390-ccw/net: fix a possible memory leak in get_uuid()

Posted by luoyifan@cmss.chinamobile.com 3 days ago
There is a possible memory leak in get_uuid(). Should free allocated mem
before 
return NULL.

Signed-off-by: Yifan Luo <luoyifan@cmss.chinamobile.com>
---
 pc-bios/s390-ccw/netmain.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
index f3542cb2cf1..f2dcc01e272 100644
--- a/pc-bios/s390-ccw/netmain.c
+++ b/pc-bios/s390-ccw/netmain.c
@@ -269,6 +269,7 @@ static const char *get_uuid(void)
                  : "d" (r0), "d" (r1), [addr] "a" (buf)
                  : "cc", "memory");
     if (cc) {
+        free(mem);
         return NULL;
     }
 
-- 
2.21.0




Re: [Qemu-devel] [PATCH] pc-bios/s390-ccw/net: fix a possible memory leak in get_uuid()

Posted by Cornelia Huck 3 days ago
On Wed, 14 Aug 2019 14:14:26 +0800
<luoyifan@cmss.chinamobile.com> wrote:

> There is a possible memory leak in get_uuid(). Should free allocated mem
> before 
> return NULL.
> 
> Signed-off-by: Yifan Luo <luoyifan@cmss.chinamobile.com>
> ---
>  pc-bios/s390-ccw/netmain.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
> index f3542cb2cf1..f2dcc01e272 100644
> --- a/pc-bios/s390-ccw/netmain.c
> +++ b/pc-bios/s390-ccw/netmain.c
> @@ -269,6 +269,7 @@ static const char *get_uuid(void)
>                   : "d" (r0), "d" (r1), [addr] "a" (buf)
>                   : "cc", "memory");
>      if (cc) {
> +        free(mem);
>          return NULL;
>      }
>  

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Re: [Qemu-devel] [PATCH] pc-bios/s390-ccw/net: fix a possible memory leak in get_uuid()

Posted by Thomas Huth 3 days ago
On 8/14/19 8:14 AM, luoyifan@cmss.chinamobile.com wrote:
> There is a possible memory leak in get_uuid(). Should free allocated mem
> before 
> return NULL.
> 
> Signed-off-by: Yifan Luo <luoyifan@cmss.chinamobile.com>
> ---
>  pc-bios/s390-ccw/netmain.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
> index f3542cb2cf1..f2dcc01e272 100644
> --- a/pc-bios/s390-ccw/netmain.c
> +++ b/pc-bios/s390-ccw/netmain.c
> @@ -269,6 +269,7 @@ static const char *get_uuid(void)
>                   : "d" (r0), "d" (r1), [addr] "a" (buf)
>                   : "cc", "memory");
>      if (cc) {
> +        free(mem);
>          return NULL;
>      }
>  
> 

Thanks, I queued the patch to my s390-ccw-bios branch.

Reviewed-by: Thomas Huth <thuth@redhat.com>