Re: [PATCH 2/6] block: bdrv_reopen_multiple(): fix leak of tran object

2021-05-04 Thread Vladimir Sementsov-Ogievskiy

03.05.2021 18:52, Alberto Garcia wrote:

On Mon 03 May 2021 01:33:58 PM CEST, Vladimir Sementsov-Ogievskiy 
 wrote:

We have one path, where tran object is created, but we don't touch and
don't free it in any way: "goto cleanup" in first loop with calls to
bdrv_flush().

Fix it simply moving tran_new() call below that loop.

Reported-by: Coverity (CID 1452772)
Reported-by: Peter Maydell 
Suggested-by: Peter Maydell 
Fixes: 72373e40fbc7e4218061a8211384db362d3e7348
Signed-off-by: Vladimir Sementsov-Ogievskiy 


Reviewed-by: Alberto Garcia 



Thanks!  Still, now I see that Kevin's patch is better ([PATCH 2/2] block: Fix 
Transaction leak in bdrv_reopen_multiple())


--
Best regards,
Vladimir



Re: [PATCH 2/6] block: bdrv_reopen_multiple(): fix leak of tran object

2021-05-03 Thread Alberto Garcia
On Mon 03 May 2021 01:33:58 PM CEST, Vladimir Sementsov-Ogievskiy 
 wrote:
> We have one path, where tran object is created, but we don't touch and
> don't free it in any way: "goto cleanup" in first loop with calls to
> bdrv_flush().
>
> Fix it simply moving tran_new() call below that loop.
>
> Reported-by: Coverity (CID 1452772)
> Reported-by: Peter Maydell 
> Suggested-by: Peter Maydell 
> Fixes: 72373e40fbc7e4218061a8211384db362d3e7348
> Signed-off-by: Vladimir Sementsov-Ogievskiy 

Reviewed-by: Alberto Garcia 

Berto



[PATCH 2/6] block: bdrv_reopen_multiple(): fix leak of tran object

2021-05-03 Thread Vladimir Sementsov-Ogievskiy
We have one path, where tran object is created, but we don't touch and
don't free it in any way: "goto cleanup" in first loop with calls to
bdrv_flush().

Fix it simply moving tran_new() call below that loop.

Reported-by: Coverity (CID 1452772)
Reported-by: Peter Maydell 
Suggested-by: Peter Maydell 
Fixes: 72373e40fbc7e4218061a8211384db362d3e7348
Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 block.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block.c b/block.c
index 728aa34b2f..c4023ab4f4 100644
--- a/block.c
+++ b/block.c
@@ -4047,7 +4047,7 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, 
Error **errp)
 {
 int ret = -1;
 BlockReopenQueueEntry *bs_entry, *next;
-Transaction *tran = tran_new();
+Transaction *tran;
 g_autoptr(GHashTable) found = NULL;
 g_autoptr(GSList) refresh_list = NULL;
 
@@ -4061,6 +4061,8 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, 
Error **errp)
 }
 }
 
+tran = tran_new();
+
 QTAILQ_FOREACH(bs_entry, bs_queue, entry) {
 assert(bs_entry->state.bs->quiesce_counter > 0);
 ret = bdrv_reopen_prepare(&bs_entry->state, bs_queue, tran, errp);
-- 
2.29.2