Re: [Qemu-devel] [PATCH] qemu-io: Fix memory leak in 'aio_write -z'

2016-05-09 Thread Eric Blake
On 05/09/2016 04:03 AM, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf 
> ---
>  qemu-io-cmds.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Eric Blake 

Perhaps it would be easier to convert all the mid-function returns into
'goto cleanup', so that we don't have to repeat the cleanups everywhere,
but that's more invasive.

> 
> diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
> index e34f777..41580b5 100644
> --- a/qemu-io-cmds.c
> +++ b/qemu-io-cmds.c
> @@ -1699,6 +1699,7 @@ static int aio_write_f(BlockBackend *blk, int argc, 
> char **argv)
>  int64_t count = cvtnum(argv[optind]);
>  if (count < 0) {
>  print_cvtnum_err(count, argv[optind]);
> +g_free(ctx);
>  return 0;
>  }
>  
> 

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH] qemu-io: Fix memory leak in 'aio_write -z'

2016-05-09 Thread Kevin Wolf
Signed-off-by: Kevin Wolf 
---
 qemu-io-cmds.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index e34f777..41580b5 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -1699,6 +1699,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char 
**argv)
 int64_t count = cvtnum(argv[optind]);
 if (count < 0) {
 print_cvtnum_err(count, argv[optind]);
+g_free(ctx);
 return 0;
 }
 
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH] qemu-io: Fix memory leak

2009-11-20 Thread Kevin Wolf
Am 20.11.2009 09:05, schrieb Amit Shah:
> On (Wed) Nov 18 2009 [10:42:59], Kevin Wolf wrote:
>> Signed-off-by: Kevin Wolf 
>> ---
>>  qemu-io.c |   10 ++
>>  1 files changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/qemu-io.c b/qemu-io.c
>> index cac72e9..c84b361 100644
>> --- a/qemu-io.c
>> +++ b/qemu-io.c
>> @@ -129,7 +129,8 @@ create_iovec(QEMUIOVector *qiov, char **argv, int 
>> nr_iov, int pattern)
>>  {
>>  size_t *sizes = calloc(nr_iov, sizeof(size_t));
>>  size_t count = 0;
>> -void *buf, *p;
>> +void *buf = NULL;
>> +void *p;
>>  int i;
> 
> I'd prefer the init to happen after the declarations -- brings in
> consistent style, puts declarations in one blob and makes
> initialisations explicit.

In the context of this function it would be inconsistent, and I'd be
surprised if the rest of the qemu code was consistent with your
expectations. After all, it's a matter of taste, and in such questions I
tend to stick with the style of the surrounding code.

Kevin




Re: [Qemu-devel] [PATCH] qemu-io: Fix memory leak

2009-11-20 Thread Amit Shah
On (Wed) Nov 18 2009 [10:42:59], Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf 
> ---
>  qemu-io.c |   10 ++
>  1 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/qemu-io.c b/qemu-io.c
> index cac72e9..c84b361 100644
> --- a/qemu-io.c
> +++ b/qemu-io.c
> @@ -129,7 +129,8 @@ create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, 
> int pattern)
>  {
>   size_t *sizes = calloc(nr_iov, sizeof(size_t));
>   size_t count = 0;
> - void *buf, *p;
> + void *buf = NULL;
> + void *p;
>   int i;

I'd prefer the init to happen after the declarations -- brings in
consistent style, puts declarations in one blob and makes
initialisations explicit.


Amit




Re: [Qemu-devel] [PATCH] qemu-io: Fix memory leak

2009-11-18 Thread Christoph Hellwig
Looks good,


Reviewed-by: Christoph Hellwig 





[Qemu-devel] [PATCH] qemu-io: Fix memory leak

2009-11-18 Thread Kevin Wolf
Signed-off-by: Kevin Wolf 
---
 qemu-io.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/qemu-io.c b/qemu-io.c
index cac72e9..c84b361 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -129,7 +129,8 @@ create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, 
int pattern)
 {
size_t *sizes = calloc(nr_iov, sizeof(size_t));
size_t count = 0;
-   void *buf, *p;
+   void *buf = NULL;
+   void *p;
int i;
 
for (i = 0; i < nr_iov; i++) {
@@ -139,19 +140,19 @@ create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, 
int pattern)
len = cvtnum(arg);
if (len < 0) {
printf("non-numeric length argument -- %s\n", arg);
-   return NULL;
+   goto fail;
}
 
/* should be SIZE_T_MAX, but that doesn't exist */
if (len > UINT_MAX) {
printf("too large length argument -- %s\n", arg);
-   return NULL;
+   goto fail;
}
 
if (len & 0x1ff) {
printf("length argument %lld is not sector aligned\n",
len);
-   return NULL;
+   goto fail;
}
 
sizes[i] = len;
@@ -167,6 +168,7 @@ create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, 
int pattern)
p += sizes[i];
}
 
+fail:
free(sizes);
return buf;
 }
-- 
1.6.2.5