[Qemu-devel] [PATCH] qga: fix 'driver' leak in guest-get-fsinfo

Marc-André Lureau posted 1 patch 7 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180705161629.13734-1-marcandre.lureau@redhat.com
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
qga/commands-posix.c | 1 +
1 file changed, 1 insertion(+)
[Qemu-devel] [PATCH] qga: fix 'driver' leak in guest-get-fsinfo
Posted by Marc-André Lureau 7 years, 4 months ago
'driver' is leaked when the loop is not broken.

Leak introduced by commit 743c71d03c20d64f2bae5fba6f26cdf5e4b1bda6,
spotted by ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qga/commands-posix.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 233f78a406..c46767b0dd 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -890,6 +890,7 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
             break;
         }
 
+        g_free(driver);
         if (sscanf(p, "/%x:%x:%x.%x%n",
                           pci, pci + 1, pci + 2, pci + 3, &pcilen) == 4) {
             p += pcilen;
-- 
2.18.0.rc1


Re: [Qemu-devel] [PATCH] qga: fix 'driver' leak in guest-get-fsinfo
Posted by Laszlo Ersek 7 years, 4 months ago
On 07/05/18 18:16, Marc-André Lureau wrote:
> 'driver' is leaked when the loop is not broken.
> 
> Leak introduced by commit 743c71d03c20d64f2bae5fba6f26cdf5e4b1bda6,
> spotted by ASAN.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  qga/commands-posix.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 233f78a406..c46767b0dd 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -890,6 +890,7 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
>              break;
>          }
>  
> +        g_free(driver);
>          if (sscanf(p, "/%x:%x:%x.%x%n",
>                            pci, pci + 1, pci + 2, pci + 3, &pcilen) == 4) {
>              p += pcilen;
> 

Sorry, I should have noticed this in review.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Laszlo

Re: [Qemu-devel] [PATCH] qga: fix 'driver' leak in guest-get-fsinfo
Posted by Michael Roth 7 years, 4 months ago
Quoting Marc-André Lureau (2018-07-05 11:16:29)
> 'driver' is leaked when the loop is not broken.
> 
> Leak introduced by commit 743c71d03c20d64f2bae5fba6f26cdf5e4b1bda6,
> spotted by ASAN.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Thanks, applied to qga tree:
  https://github.com/mdroth/qemu/commits/qga

> ---
>  qga/commands-posix.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 233f78a406..c46767b0dd 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -890,6 +890,7 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
>              break;
>          }
> 
> +        g_free(driver);
>          if (sscanf(p, "/%x:%x:%x.%x%n",
>                            pci, pci + 1, pci + 2, pci + 3, &pcilen) == 4) {
>              p += pcilen;
> -- 
> 2.18.0.rc1
>