Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-for…
Browse files Browse the repository at this point in the history
…-6.0-pull-request' into staging

Trivial patches 20210118

Fix memory leaks
Use qemu_log_mask(GUEST_ERROR) rather than error_report().

# gpg: Signature made Mon 18 Jan 2021 11:31:10 GMT
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/trivial-branch-for-6.0-pull-request:
  hw/ide/ahci: Replace fprintf() by qemu_log_mask(GUEST_ERROR)
  misc/mos6522: Use timer_free() in the finalize function to avoid memleak
  pl031: Use timer_free() in the finalize function to avoid memleaks
  hw/virtio-pci: Replace error_report() by qemu_log_mask(GUEST_ERROR)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jan 18, 2021
2 parents 8814b13 + 580e733 commit e43d564
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
8 changes: 5 additions & 3 deletions hw/ide/ahci.c
Expand Up @@ -465,8 +465,9 @@ static void ahci_mem_write(void *opaque, hwaddr addr,

/* Only aligned reads are allowed on AHCI */
if (addr & 3) {
fprintf(stderr, "ahci: Mis-aligned write to addr 0x"
TARGET_FMT_plx "\n", addr);
qemu_log_mask(LOG_GUEST_ERROR,
"ahci: Mis-aligned write to addr 0x%03" HWADDR_PRIX "\n",
addr);
return;
}

Expand Down Expand Up @@ -1111,7 +1112,8 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis,
g_assert(is_ncq(ncq_fis->command));
if (ncq_tfs->used) {
/* error - already in use */
fprintf(stderr, "%s: tag %d already used\n", __func__, tag);
qemu_log_mask(LOG_GUEST_ERROR, "%s: tag %d already used\n",
__func__, tag);
return;
}

Expand Down
9 changes: 9 additions & 0 deletions hw/misc/mos6522.c
Expand Up @@ -490,6 +490,14 @@ static void mos6522_init(Object *obj)
s->timers[1].timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, mos6522_timer2, s);
}

static void mos6522_finalize(Object *obj)
{
MOS6522State *s = MOS6522(obj);

timer_free(s->timers[0].timer);
timer_free(s->timers[1].timer);
}

static Property mos6522_properties[] = {
DEFINE_PROP_UINT64("frequency", MOS6522State, frequency, 0),
DEFINE_PROP_END_OF_LIST()
Expand Down Expand Up @@ -519,6 +527,7 @@ static const TypeInfo mos6522_type_info = {
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(MOS6522State),
.instance_init = mos6522_init,
.instance_finalize = mos6522_finalize,
.abstract = true,
.class_size = sizeof(MOS6522DeviceClass),
.class_init = mos6522_class_init,
Expand Down
8 changes: 8 additions & 0 deletions hw/rtc/pl031.c
Expand Up @@ -194,6 +194,13 @@ static void pl031_init(Object *obj)
s->timer = timer_new_ns(rtc_clock, pl031_interrupt, s);
}

static void pl031_finalize(Object *obj)
{
PL031State *s = PL031(obj);

timer_free(s->timer);
}

static int pl031_pre_save(void *opaque)
{
PL031State *s = opaque;
Expand Down Expand Up @@ -329,6 +336,7 @@ static const TypeInfo pl031_info = {
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(PL031State),
.instance_init = pl031_init,
.instance_finalize = pl031_finalize,
.class_init = pl031_class_init,
};

Expand Down
6 changes: 4 additions & 2 deletions hw/virtio/virtio-pci.c
Expand Up @@ -27,6 +27,7 @@
#include "hw/qdev-properties.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "hw/pci/msi.h"
#include "hw/pci/msix.h"
Expand Down Expand Up @@ -365,8 +366,9 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
virtio_queue_set_vector(vdev, vdev->queue_sel, val);
break;
default:
error_report("%s: unexpected address 0x%x value 0x%x",
__func__, addr, val);
qemu_log_mask(LOG_GUEST_ERROR,
"%s: unexpected address 0x%x value 0x%x\n",
__func__, addr, val);
break;
}
}
Expand Down

0 comments on commit e43d564

Please sign in to comment.