Skip to contentSkip to conversation

blockdev memory leaks

PATCH Applied Markus Armbruster 4 participants 8 messages Feb 8, 2011 – Feb 9, 2011

lore
Share & tools
lore
#0 lore raw

cover blockdev memory leaks

Markus Armbruster (2):
blockdev: Plug memory leak in drive_uninit()
blockdev: Plug memory leak in drive_init() error paths

 blockdev.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/2 blockdev: Plug memory leak in drive_uninit()

Started leaking in commit 1dae12e6.

---
 blockdev.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
blockdev.c +1 -0
index ecfadc1..24d7658 100644
@@ -182,6 +182,7 @@ static void drive_uninit(DriveInfo *dinfo)
 {
     qemu_opts_del(dinfo->opts);
     bdrv_delete(dinfo->bdrv);
+    qemu_free(dinfo->id);
     QTAILQ_REMOVE(&drives, dinfo, next);
     qemu_free(dinfo);
 }
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 2/2 blockdev: Plug memory leak in drive_init() error paths

In reply to Markus Armbruster

Should have spotted this when doing commit 319ae529.

---
 blockdev.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
blockdev.c +9 -2
index 24d7658..0690cc8 100644
@@ -526,7 +526,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
     } else if (ro == 1) {
         if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) {
             error_report("readonly not supported by this bus type");
-            return NULL;
+            goto err;
         }
     }
 
@@ -536,12 +536,19 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
     if (ret < 0) {
         error_report("could not open disk image %s: %s",
                      file, strerror(-ret));
-        return NULL;
+        goto err;
     }
 
     if (bdrv_key_required(dinfo->bdrv))
         autostart = 0;
     return dinfo;
+
+err:
+    bdrv_delete(dinfo->bdrv);
+    qemu_free(dinfo->id);
+    QTAILQ_REMOVE(&drives, dinfo, next);
+    qemu_free(dinfo);
+    return NULL;
 }
 
 void do_commit(Monitor *mon, const QDict *qdict)
Signature · 1 line
1.7.2.3
Applied
#3 lore raw
In reply to Markus Armbruster

Am 08.02.2011 15:12, schrieb Markus Armbruster:

Quoted 6 lines

Markus Armbruster (2):
blockdev: Plug memory leak in drive_uninit()
blockdev: Plug memory leak in drive_init() error paths

 blockdev.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

Thanks, applied all to the block branch.

Kevin

#4 lore raw
In reply to Markus Armbruster

Hi Justin,

Am 08.02.2011 15:12, schrieb Markus Armbruster:

Quoted 6 lines

Markus Armbruster (2):
blockdev: Plug memory leak in drive_uninit()
blockdev: Plug memory leak in drive_init() error paths

 blockdev.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

How this series made its way into stable was a bit surprising for me. You may not be aware yet of the expectations that I (and probably others) have in the process of patches being applied to stable. No harm done, but maybe something to consider for future patches, so let me just mention some points:

I saw that you already merged these patches into the stable tree, even though they are not master yet. I think usually stable should only get cherry-picks from master. There are exceptions of course (e.g. when something will be fixed differently in master), but I don't think this is one of them.

Also I noticed that you didn't add your Signed-off-by when applying the patches. As I understand it, you should do this for any patch that you apply directly (i.e. that you don't get via a git pull)

I only caught this by chance. If you sent an email ("Thanks, applied to ...") after you have applied a patch or pulled from somewhere, it would be more obvious to the rest of us what happens in stable.

Kevin

#5 lore raw
Quoted 22 lines · Kevin Wolf

Hi Justin,

Am 08.02.2011 15:12, schrieb Markus Armbruster:

Quoted 6 lines

Markus Armbruster (2):
blockdev: Plug memory leak in drive_uninit()
blockdev: Plug memory leak in drive_init() error paths

 blockdev.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

How this series made its way into stable was a bit surprising for me. You may not be aware yet of the expectations that I (and probably others) have in the process of patches being applied to stable. No harm done, but maybe something to consider for future patches, so let me just mention some points:

I saw that you already merged these patches into the stable tree, even though they are not master yet. I think usually stable should only get cherry-picks from master. There are exceptions of course (e.g. when something will be fixed differently in master), but I don't think this is one of them.

Quoted 7 lines

Also I noticed that you didn't add your Signed-off-by when applying the patches. As I understand it, you should do this for any patch that you apply directly (i.e. that you don't get via a git pull)

I only caught this by chance. If you sent an email ("Thanks, applied to ...") after you have applied a patch or pulled from somewhere, it would be more obvious to the rest of us what happens in stable.

Indeed, that was my fault... I had applied them for testing, and pushed to the wrong tree. I have made some local changes to insure that this does not happen in the future. The process is, pathches should be in master first, or their be a very good reason that they are not (bugs no longer apply to master, or different and more invasive fix is used in master). At this point in the cycle, where there is so little divergence from master, there is no reason that anything in stable is not in master.

Justin

#6 lore raw
Quoted 29 lines · Justin M. Forbes
Quoted 27 lines · Kevin Wolf

Hi Justin,

Am 08.02.2011 15:12, schrieb Markus Armbruster:

Quoted 7 lines

Markus Armbruster (2):
blockdev: Plug memory leak in drive_uninit()
blockdev: Plug memory leak in drive_init() error paths

  blockdev.c |   12 ++++++++++--
  1 files changed, 10 insertions(+), 2 deletions(-)

How this series made its way into stable was a bit surprising for me. You may not be aware yet of the expectations that I (and probably others) have in the process of patches being applied to stable. No harm done, but maybe something to consider for future patches, so let me just mention some points:

I saw that you already merged these patches into the stable tree, even though they are not master yet. I think usually stable should only get cherry-picks from master. There are exceptions of course (e.g. when something will be fixed differently in master), but I don't think this is one of them.

Also I noticed that you didn't add your Signed-off-by when applying the patches. As I understand it, you should do this for any patch that you apply directly (i.e. that you don't get via a git pull)

Quoted 5 lines
Quoted 4 lines

I only caught this by chance. If you sent an email ("Thanks, applied to ...") after you have applied a patch or pulled from somewhere, it would be more obvious to the rest of us what happens in stable.

Indeed, that was my fault...

No worries, it happens.

Regards,

Anthony Liguori

Quoted 13 lines

I had applied them for testing, and pushed
to the wrong tree. I have made some local changes to insure that this does not happen in the future. The process is, pathches should be in master first, or their be a very good reason that they are not (bugs no longer apply to master, or different and more invasive fix is used in master). At this point in the cycle, where there is so little divergence from master, there is no reason that anything in stable is not in master.

Justin

#7 lore raw
In reply to Justin M. Forbes

Am 09.02.2011 15:09, schrieb Justin M. Forbes:

Quoted 27 lines · Kevin Wolf
Quoted 26 lines

Hi Justin,

Am 08.02.2011 15:12, schrieb Markus Armbruster:

Quoted 6 lines

Markus Armbruster (2):
blockdev: Plug memory leak in drive_uninit()
blockdev: Plug memory leak in drive_init() error paths

 blockdev.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

How this series made its way into stable was a bit surprising for me. You may not be aware yet of the expectations that I (and probably others) have in the process of patches being applied to stable. No harm done, but maybe something to consider for future patches, so let me just mention some points:

I saw that you already merged these patches into the stable tree, even though they are not master yet. I think usually stable should only get cherry-picks from master. There are exceptions of course (e.g. when something will be fixed differently in master), but I don't think this is one of them.

Also I noticed that you didn't add your Signed-off-by when applying the patches. As I understand it, you should do this for any patch that you apply directly (i.e. that you don't get via a git pull)

Quoted 7 lines
Quoted 3 lines

I only caught this by chance. If you sent an email ("Thanks, applied to ...") after you have applied a patch or pulled from somewhere, it would be more obvious to the rest of us what happens in stable.

Indeed, that was my fault... I had applied them for testing, and pushed to the wrong tree. I have made some local changes to insure that this does not happen in the future.

Okay, if it was an accident, no problem.

I was just trying to make sure that we're all having the same expectation of how it should work.

Kevin