Skip to contentSkip to conversation

More miscellaneous error handling fixes

PATCH In review Markus Armbruster 5 participants 17 messages May 5, 2020 – May 6, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover More miscellaneous error handling fixes

v2:
* PATCH 2: missing return [Paul]
* PATCH 3: commit message typo [David]
* PATCH 5: error message tidied up [Eric, Philippe]
* PATCH 7: commit message pasto
* Old PATCH 4 dropped [Matthew]

Cc Paul Durrant <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Eric Blake <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>

Markus Armbruster (10):
nvdimm: Plug memory leak in uuid property setter
xen: Fix and improve handling of device_add usb-host errors s390x/cpumodel: Fix harmless misuse of visit_check_struct() tests/migration: Tighten error checking
error: Use error_reportf_err() where appropriate mips/malta: Fix create_cps() error handling mips/boston: Fix boston_mach_init() error handling mips/boston: Plug memory leak in boston_mach_init() arm/sabrelite: Consistently use &error_fatal in sabrelite_init()
i386: Fix x86_cpu_load_model() error API violation

 chardev/char-socket.c        |  5 +++--
 hw/arm/sabrelite.c           |  7 +------
 hw/mem/nvdimm.c              |  1 -
 hw/mips/boston.c             | 17 +++++++----------
 hw/mips/mips_malta.c         | 15 ++++++---------
 hw/sd/pxa2xx_mmci.c          |  4 ++--
 hw/sd/sd.c                   |  4 ++--
 hw/usb/dev-mtp.c             |  9 +++++----
 hw/usb/xen-usb.c             | 19 +++++++++----------
 qemu-nbd.c                   |  7 +++----
 scsi/qemu-pr-helper.c        |  4 ++--
 target/i386/cpu.c            | 25 ++++++++++++++++---------
 target/s390x/cpu_models.c    |  2 +-
 tests/qtest/migration-test.c |  4 ++--
 14 files changed, 59 insertions(+), 64 deletions(-)
Signature · 1 line
2.21.1
#1 lore raw

PATCH v2 1/10 nvdimm: Plug memory leak in uuid property setter

nvdimm_set_uuid() leaks memory on qemu_uuid_parse() failure. Fix that.

Fixes 6c5627bb24dcd68c997857a8b671617333b1289f
Cc Xiao Guangrong <[email protected]>
Cc Shivaprasad G Bhat <[email protected]>
---
 hw/mem/nvdimm.c | 1 -
 1 file changed, 1 deletion(-)
hw/mem/nvdimm.c +0 -1
index 8e426d24bb..d5752f7bf6 100644
@@ -97,7 +97,6 @@ static void nvdimm_set_uuid(Object *obj, Visitor *v, const char *name,
     if (qemu_uuid_parse(value, &nvdimm->uuid) != 0) {
         error_setg(errp, "Property '%s.%s' has invalid value",
                    object_get_typename(obj), name);
-        goto out;
     }
     g_free(value);
 
Signature · 1 line
2.21.1
Tested-by Reviewed-by on v2 1/10
#2 lore raw

Re: [PATCH v2 01/10] nvdimm: Plug memory leak in uuid property setter

Quoted 7 lines · Markus Armbruster

nvdimm_set_uuid() leaks memory on qemu_uuid_parse() failure. Fix that.

Fixes 6c5627bb24dcd68c997857a8b671617333b1289f
Cc Xiao Guangrong <[email protected]>
Cc Shivaprasad G Bhat <[email protected]>

Thanks for finding and fixing this Markus.

Regards,
Shivaprasad

Quoted 16 lines
---
  hw/mem/nvdimm.c | 1 -
  1 file changed, 1 deletion(-)
hw/mem/nvdimm.c +0 -1
index 8e426d24bb..d5752f7bf6 100644
@@ -97,7 +97,6 @@ static void nvdimm_set_uuid(Object *obj, Visitor *v, const char *name,
      if (qemu_uuid_parse(value, &nvdimm->uuid) != 0) {
          error_setg(errp, "Property '%s.%s' has invalid value",
                     object_get_typename(obj), name);
-        goto out;
      }
      g_free(value);
 
#3 lore raw

PATCH v2 2/10 xen: Fix and improve handling of device_add usb-host errors

In reply to Markus Armbruster

usbback_portid_add() leaks the error when qdev_device_add() fails. Fix that. While there, use the error to improve the error message.

The qemu_opts_from_qdict() similarly leaks on failure. But any failure there is a programming error. Pass &error_abort.

Fixes 816ac92ef769f9ffc534e49a1bb6177bddce7aa2
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>
Cc Paul Durrant <[email protected]>
Cc Gerd Hoffmann <[email protected]>
---
 hw/usb/xen-usb.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
hw/usb/xen-usb.c +9 -10
index 961190d0f7..4d266d7bb4 100644
@@ -30,6 +30,7 @@
 #include "hw/usb.h"
 #include "hw/xen/xen-legacy-backend.h"
 #include "monitor/qdev.h"
+#include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
 
@@ -755,13 +756,16 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
     qdict_put_int(qdict, "port", port);
     qdict_put_int(qdict, "hostbus", atoi(busid));
     qdict_put_str(qdict, "hostport", portname);
-    opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err);
-    if (local_err) {
-        goto err;
-    }
+    opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict,
+                                &error_abort);
     usbif->ports[port - 1].dev = USB_DEVICE(qdev_device_add(opts, &local_err));
     if (!usbif->ports[port - 1].dev) {
-        goto err;
+        qobject_unref(qdict);
+        xen_pv_printf(&usbif->xendev, 0,
+                      "device %s could not be opened: %s\n",
+                      busid, error_get_pretty(local_err));
+        error_free(local_err);
+        return;
     }
     qobject_unref(qdict);
     speed = usbif->ports[port - 1].dev->speed;
@@ -793,11 +797,6 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
     usbback_hotplug_enq(usbif, port);
 
     TR_BUS(&usbif->xendev, "port %d attached\n", port);
-    return;
-
-err:
-    qobject_unref(qdict);
-    xen_pv_printf(&usbif->xendev, 0, "device %s could not be opened\n", busid);
 }
 
 static void usbback_process_port(struct usbback_info *usbif, unsigned port)
Signature · 1 line
2.21.1
Acked-by on v2 2/10
#4 lore raw

RE: [PATCH v2 02/10] xen: Fix and improve handling of device_add usb-host errors

Quoted 14 lines

-----Original Message-----
From: Markus Armbruster <[email protected]>
Sent: 05 May 2020 11:19
To: [email protected]
Cc: Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>; Paul Durrant <[email protected]>; Gerd Hoffmann <[email protected]>; [email protected]
Subject: [PATCH v2 02/10] xen: Fix and improve handling of device_add usb-host errors

usbback_portid_add() leaks the error when qdev_device_add() fails. Fix that. While there, use the error to improve the error message.

The qemu_opts_from_qdict() similarly leaks on failure. But any failure there is a programming error. Pass &error_abort.

Quoted 7 lines
Fixes 816ac92ef769f9ffc534e49a1bb6177bddce7aa2
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>
Cc Paul Durrant <[email protected]>
Cc Gerd Hoffmann <[email protected]>
#5 lore raw

PATCH v2 3/10 s390x/cpumodel: Fix harmless misuse of visit_check_struct()

In reply to Markus Armbruster

Commit e47970f51d "s390x/cpumodel: Fix query-cpu-model-FOO error API violations" neglected to change visit_check_struct()'s Error ** argument along with the others. If visit_check_struct() failed, we'd take the success path. Fortunately, it can't fail here:
qobject_input_check_struct() checks we consumed the whole dictionary, and to get here, we did. Fix it anyway.

---
 target/s390x/cpu_models.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/cpu_models.c +1 -1
index 7c32180269..87a8028ad3 100644
@@ -524,7 +524,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
             }
         }
         if (!err) {
-            visit_check_struct(visitor, errp);
+            visit_check_struct(visitor, &err);
         }
         visit_end_struct(visitor, NULL);
         visit_free(visitor);
Signature · 1 line
2.21.1
#6 lore raw

PATCH v2 4/10 tests/migration: Tighten error checking

In reply to Markus Armbruster

migrate_get_socket_address() neglects to check visit_type_SocketAddressList() failure. This smells like a leak, but it actually will crash dereferencing @addrs. Pass &error_abort to remove the code smell.

---
 tests/qtest/migration-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qtest/migration-test.c +2 -2
index 2568c9529c..dc3490c9fa 100644
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 
 #include "libqtest.h"
+#include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
 #include "qemu/module.h"
 #include "qemu/option.h"
@@ -301,7 +302,6 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter)
 {
     QDict *rsp;
     char *result;
-    Error *local_err = NULL;
     SocketAddressList *addrs;
     Visitor *iv = NULL;
     QObject *object;
@@ -310,7 +310,7 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter)
     object = qdict_get(rsp, parameter);
 
     iv = qobject_input_visitor_new(object);
-    visit_type_SocketAddressList(iv, NULL, &addrs, &local_err);
+    visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort);
     visit_free(iv);
 
     /* we are only using a single address */
Signature · 1 line
2.21.1
Reviewed-by on v2 4/10
#7 lore raw

Re: [PATCH v2 04/10] tests/migration: Tighten error checking

Quoted 32 lines · Markus Armbruster

migrate_get_socket_address() neglects to check visit_type_SocketAddressList() failure. This smells like a leak, but it actually will crash dereferencing @addrs. Pass &error_abort to remove the code smell.

---
  tests/qtest/migration-test.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
tests/qtest/migration-test.c +1 -1
index 2568c9529c..dc3490c9fa 100644
@@ -13,6 +13,7 @@
  #include "qemu/osdep.h"
 
  #include "libqtest.h"
+#include "qapi/error.h"
  #include "qapi/qmp/qdict.h"
  #include "qemu/module.h"
  #include "qemu/option.h"
@@ -301,7 +302,6 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter)
  {
      QDict *rsp;
      char *result;
-    Error *local_err = NULL;
      SocketAddressList *addrs;
      Visitor *iv = NULL;
      QObject *object;

tests/qtest/migration-test.c static char *migrate_get_socket_address(QTestState *who, const char *parameter) · line 316

Quoted 8 lines
tests/qtest/migration-test.c +1 -1
@@ -310,7 +310,7 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter)
      object = qdict_get(rsp, parameter);
 
      iv = qobject_input_visitor_new(object);
-    visit_type_SocketAddressList(iv, NULL, &addrs, &local_err);
+    visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort);
      visit_free(iv);
 
      /* we are only using a single address */
#8 lore raw

PATCH v2 5/10 error: Use error_reportf_err() where appropriate

In reply to Markus Armbruster

Replace

    error_report("...: %s", ..., error_get_pretty(err));

by

    error_reportf_err(err, "...: ", ...);

One of the replaced messages lacked a colon. Add it.

---
 chardev/char-socket.c | 5 +++--
 hw/sd/pxa2xx_mmci.c   | 4 ++--
 hw/sd/sd.c            | 4 ++--
 hw/usb/dev-mtp.c      | 9 +++++----
 qemu-nbd.c            | 7 +++----
 scsi/qemu-pr-helper.c | 4 ++--
 6 files changed, 17 insertions(+), 16 deletions(-)
chardev/char-socket.c +3 -2
index 185fe38dda..e5ee685f8c 100644
@@ -138,8 +138,9 @@ static void check_report_connect_error(Chardev *chr,
     SocketChardev *s = SOCKET_CHARDEV(chr);
 
     if (!s->connect_err_reported) {
-        error_report("Unable to connect character device %s: %s",
-                     chr->label, error_get_pretty(err));
+        error_reportf_err(err,
+                          "Unable to connect character device %s: ",
+                          chr->label);
         s->connect_err_reported = true;
     }
     qemu_chr_socket_restart_timer(chr);
hw/sd/pxa2xx_mmci.c +2 -2
index 8f9ab0ec16..f9c50ddda5 100644
@@ -497,12 +497,12 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
     carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"), TYPE_SD_CARD);
     qdev_prop_set_drive(carddev, "drive", blk, &err);
     if (err) {
-        error_report("failed to init SD card: %s", error_get_pretty(err));
+        error_reportf_err(err, "failed to init SD card: ");
         return NULL;
     }
     object_property_set_bool(OBJECT(carddev), true, "realized", &err);
     if (err) {
-        error_report("failed to init SD card: %s", error_get_pretty(err));
+        error_reportf_err(err, "failed to init SD card: ");
         return NULL;
     }
 
hw/sd/sd.c +2 -2
index 71a9af09ab..3c06a0ac6d 100644
@@ -703,13 +703,13 @@ SDState *sd_init(BlockBackend *blk, bool is_spi)
     dev = DEVICE(obj);
     qdev_prop_set_drive(dev, "drive", blk, &err);
     if (err) {
-        error_report("sd_init failed: %s", error_get_pretty(err));
+        error_reportf_err(err, "sd_init failed: ");
         return NULL;
     }
     qdev_prop_set_bit(dev, "spi", is_spi);
     object_property_set_bool(obj, true, "realized", &err);
     if (err) {
-        error_report("sd_init failed: %s", error_get_pretty(err));
+        error_reportf_err(err, "sd_init failed: ");
         return NULL;
     }
 
hw/usb/dev-mtp.c +5 -4
index 20717f026b..168428156b 100644
@@ -631,8 +631,9 @@ static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
         int64_t id = qemu_file_monitor_add_watch(s->file_monitor, o->path, NULL,
                                                  file_monitor_event, s, &err);
         if (id == -1) {
-            error_report("usb-mtp: failed to add watch for %s: %s", o->path,
-                         error_get_pretty(err));
+            error_reportf_err(err,
+                              "usb-mtp: failed to add watch for %s: ",
+                              o->path);
             error_free(err);
         } else {
             trace_usb_mtp_file_monitor_event(s->dev.addr, o->path,
@@ -1276,8 +1277,8 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
 
         s->file_monitor = qemu_file_monitor_new(&err);
         if (err) {
-            error_report("usb-mtp: file monitoring init failed: %s",
-                         error_get_pretty(err));
+            error_reportf_err(err,
+                              "usb-mtp: file monitoring init failed: ");
             error_free(err);
         } else {
             QTAILQ_INIT(&s->events);
qemu-nbd.c +3 -4
index 4aa005004e..fe8b0052a2 100644
@@ -856,8 +856,7 @@ int main(int argc, char **argv)
         }
         tlscreds = nbd_get_tls_creds(tlscredsid, list, &local_err);
         if (local_err) {
-            error_report("Failed to get TLS creds %s",
-                         error_get_pretty(local_err));
+            error_reportf_err(local_err, "Failed to get TLS creds: ");
             exit(EXIT_FAILURE);
         }
     } else {
@@ -979,8 +978,8 @@ int main(int argc, char **argv)
                                              &local_err);
             if (sioc == NULL) {
                 object_unref(OBJECT(server));
-                error_report("Failed to use socket activation: %s",
-                             error_get_pretty(local_err));
+                error_reportf_err(local_err,
+                                  "Failed to use socket activation: ");
                 exit(EXIT_FAILURE);
             }
             qio_net_listener_add(server, sioc);
scsi/qemu-pr-helper.c +2 -2
index 181ed4a186..57ad830d54 100644
@@ -1030,8 +1030,8 @@ int main(int argc, char **argv)
         server_ioc = qio_channel_socket_new_fd(FIRST_SOCKET_ACTIVATION_FD,
                                                &local_err);
         if (server_ioc == NULL) {
-            error_report("Failed to use socket activation: %s",
-                         error_get_pretty(local_err));
+            error_reportf_err(local_err,
+                              "Failed to use socket activation: ");
             exit(EXIT_FAILURE);
         }
     }
Signature · 1 line
2.21.1
#9 lore raw

PATCH v2 6/10 mips/malta: Fix create_cps() error handling

In reply to Markus Armbruster

The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second

create_cps() is wrong that way. The last calls treats an error as fatal. Do that for the prior ones, too.

Fixes bff384a4fbd5d0e86939092e74e766ef0f5f592c
Cc Aleksandar Markovic <[email protected]>
Cc "Philippe Mathieu-Daudé" <[email protected]>
Cc Aurelien Jarno <[email protected]>
---
 hw/mips/mips_malta.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
hw/mips/mips_malta.c +6 -9
index e4c4de1b4e..17bf41616b 100644
@@ -1185,17 +1185,14 @@ static void create_cpu_without_cps(MachineState *ms,
 static void create_cps(MachineState *ms, MaltaState *s,
                        qemu_irq *cbus_irq, qemu_irq *i8259_irq)
 {
-    Error *err = NULL;
-
     sysbus_init_child_obj(OBJECT(s), "cps", OBJECT(&s->cps), sizeof(s->cps),
                           TYPE_MIPS_CPS);
-    object_property_set_str(OBJECT(&s->cps), ms->cpu_type, "cpu-type", &err);
-    object_property_set_int(OBJECT(&s->cps), ms->smp.cpus, "num-vp", &err);
-    object_property_set_bool(OBJECT(&s->cps), true, "realized", &err);
-    if (err != NULL) {
-        error_report("%s", error_get_pretty(err));
-        exit(1);
-    }
+    object_property_set_str(OBJECT(&s->cps), ms->cpu_type, "cpu-type",
+                            &error_fatal);
+    object_property_set_int(OBJECT(&s->cps), ms->smp.cpus, "num-vp",
+                            &error_fatal);
+    object_property_set_bool(OBJECT(&s->cps), true, "realized",
+                             &error_fatal);
 
     sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
 
Signature · 1 line
2.21.1
Reviewed-by on v2 6/10
#10 lore raw

Re: [PATCH v2 06/10] mips/malta: Fix create_cps() error handling

уторак, 05. мај 2020., Markus Armbruster <[email protected]> је написао/ла:

Quoted 15 lines

The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second

create_cps() is wrong that way. The last calls treats an error as fatal. Do that for the prior ones, too.

Fixes bff384a4fbd5d0e86939092e74e766ef0f5f592c
Cc Aleksandar Markovic <[email protected]>
Cc "Philippe Mathieu-Daudé" <[email protected]>
Cc Aurelien Jarno <[email protected]>
Quoted 5 lines
---
 hw/mips/mips_malta.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
Quoted 36 lines
hw/mips/mips_malta.c +6 -10
index e4c4de1b4e..17bf41616b 100644
@@ -1185,17 +1185,14 @@ static void create_cpu_without_cps(MachineState
 *ms,
 static void create_cps(MachineState *ms, MaltaState *s,
                        qemu_irq *cbus_irq, qemu_irq *i8259_irq)
 {
-    Error *err = NULL;
-
     sysbus_init_child_obj(OBJECT(s), "cps", OBJECT(&s->cps),
 sizeof(s->cps),
                           TYPE_MIPS_CPS);
-    object_property_set_str(OBJECT(&s->cps), ms->cpu_type, "cpu-type",
 &err);
-    object_property_set_int(OBJECT(&s->cps), ms->smp.cpus, "num-vp",
 &err);
-    object_property_set_bool(OBJECT(&s->cps), true, "realized", &err);
-    if (err != NULL) {
-        error_report("%s", error_get_pretty(err));
-        exit(1);
-    }
+    object_property_set_str(OBJECT(&s->cps), ms->cpu_type, "cpu-type",
+                            &error_fatal);
+    object_property_set_int(OBJECT(&s->cps), ms->smp.cpus, "num-vp",
+                            &error_fatal);
+    object_property_set_bool(OBJECT(&s->cps), true, "realized",
+                             &error_fatal);
 
     sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
 
--

2.21.1

#11 lore raw

PATCH v2 7/10 mips/boston: Fix boston_mach_init() error handling

In reply to Markus Armbruster

The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call.

boston_mach_init() is wrong that way. The last calls treats an error as fatal. Do that for the prior ones, too.

Fixes df1d8a1f29f567567b9d20be685a4241282e7005
Cc Paul Burton <[email protected]>
Cc Aleksandar Rikalo <[email protected]>
---
 hw/mips/boston.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
hw/mips/boston.c +5 -8
index 98ecd25e8e..2832dfa6ae 100644
@@ -458,14 +458,11 @@ static void boston_mach_init(MachineState *machine)
     sysbus_init_child_obj(OBJECT(machine), "cps", OBJECT(&s->cps),
                           sizeof(s->cps), TYPE_MIPS_CPS);
     object_property_set_str(OBJECT(&s->cps), machine->cpu_type, "cpu-type",
-                            &err);
-    object_property_set_int(OBJECT(&s->cps), machine->smp.cpus, "num-vp", &err);
-    object_property_set_bool(OBJECT(&s->cps), true, "realized", &err);
-
-    if (err != NULL) {
-        error_report("%s", error_get_pretty(err));
-        exit(1);
-    }
+                            &error_fatal);
+    object_property_set_int(OBJECT(&s->cps), machine->smp.cpus, "num-vp",
+                            &error_fatal);
+    object_property_set_bool(OBJECT(&s->cps), true, "realized",
+                             &error_fatal);
 
     sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
 
Signature · 1 line
2.21.1
Reviewed-by on v2 7/10
#12 lore raw

Re: [PATCH v2 07/10] mips/boston: Fix boston_mach_init() error handling

уторак, 05. мај 2020., Markus Armbruster <[email protected]> је написао/ла:

Quoted 6 lines

The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call.

Quoted 8 lines

boston_mach_init() is wrong that way. The last calls treats an error as fatal. Do that for the prior ones, too.

Fixes df1d8a1f29f567567b9d20be685a4241282e7005
Cc Paul Burton <[email protected]>
Cc Aleksandar Rikalo <[email protected]>

---

Quoted 34 lines
 hw/mips/boston.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
hw/mips/boston.c +5 -8
index 98ecd25e8e..2832dfa6ae 100644
@@ -458,14 +458,11 @@ static void boston_mach_init(MachineState *machine)
     sysbus_init_child_obj(OBJECT(machine), "cps", OBJECT(&s->cps),
                           sizeof(s->cps), TYPE_MIPS_CPS);
     object_property_set_str(OBJECT(&s->cps), machine->cpu_type,
 "cpu-type",
-                            &err);
-    object_property_set_int(OBJECT(&s->cps), machine->smp.cpus,
 "num-vp", &err);
-    object_property_set_bool(OBJECT(&s->cps), true, "realized", &err);
-
-    if (err != NULL) {
-        error_report("%s", error_get_pretty(err));
-        exit(1);
-    }
+                            &error_fatal);
+    object_property_set_int(OBJECT(&s->cps), machine->smp.cpus, "num-vp",
+                            &error_fatal);
+    object_property_set_bool(OBJECT(&s->cps), true, "realized",
+                             &error_fatal);
 
     sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);

--
2.21.1

#13 lore raw

PATCH v2 8/10 mips/boston: Plug memory leak in boston_mach_init()

In reply to Markus Armbruster
Fixes df1d8a1f29f567567b9d20be685a4241282e7005
Cc Paul Burton <[email protected]>
Cc Aleksandar Rikalo <[email protected]>
---
 hw/mips/boston.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/mips/boston.c +2 -2
index 2832dfa6ae..a896056be1 100644
@@ -426,7 +426,6 @@ static void boston_mach_init(MachineState *machine)
 {
     DeviceState *dev;
     BostonState *s;
-    Error *err = NULL;
     MemoryRegion *flash, *ddr_low_alias, *lcd, *platreg;
     MemoryRegion *sys_mem = get_system_memory();
     XilinxPCIEHost *pcie2;
@@ -467,7 +466,8 @@ static void boston_mach_init(MachineState *machine)
     sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
 
     flash =  g_new(MemoryRegion, 1);
-    memory_region_init_rom(flash, NULL, "boston.flash", 128 * MiB, &err);
+    memory_region_init_rom(flash, NULL, "boston.flash", 128 * MiB,
+                           &error_fatal);
     memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0);
 
     memory_region_add_subregion_overlap(sys_mem, 0x80000000, machine->ram, 0);
Signature · 1 line
2.21.1
Reviewed-by on v2 8/10
#14 lore raw

Re: [PATCH v2 08/10] mips/boston: Plug memory leak in boston_mach_init()

уторак, 05. мај 2020., Markus Armbruster <[email protected]> је написао/ла:

Quoted 9 lines
Fixes df1d8a1f29f567567b9d20be685a4241282e7005
Cc Paul Burton <[email protected]>
Cc Aleksandar Rikalo <[email protected]>
---
 hw/mips/boston.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Thank you, Markus, for spotting this error.

I am fine with you selecting this and another mips-related patch in this series in your pull request, that will be result of this series.

Truly yours,
Aleksandar

Quoted 28 lines
hw/mips/boston.c +2 -2
index 2832dfa6ae..a896056be1 100644
@@ -426,7 +426,6 @@ static void boston_mach_init(MachineState *machine)
 {
     DeviceState *dev;
     BostonState *s;
-    Error *err = NULL;
     MemoryRegion *flash, *ddr_low_alias, *lcd, *platreg;
     MemoryRegion *sys_mem = get_system_memory();
     XilinxPCIEHost *pcie2;
@@ -467,7 +466,8 @@ static void boston_mach_init(MachineState *machine)
     sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
 
     flash =  g_new(MemoryRegion, 1);
-    memory_region_init_rom(flash, NULL, "boston.flash", 128 * MiB, &err);
+    memory_region_init_rom(flash, NULL, "boston.flash", 128 * MiB,
+                           &error_fatal);
     memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0);
 
     memory_region_add_subregion_overlap(sys_mem, 0x80000000,

machine->ram, 0);
--
2.21.1

#15 lore raw

PATCH v2 9/10 arm/sabrelite: Consistently use &error_fatal in sabrelite_init()

In reply to Markus Armbruster
---
 hw/arm/sabrelite.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
hw/arm/sabrelite.c +1 -6
index e31694bb92..04f4b96591 100644
@@ -41,7 +41,6 @@ static void sabrelite_reset_secondary(ARMCPU *cpu,
 static void sabrelite_init(MachineState *machine)
 {
     FslIMX6State *s;
-    Error *err = NULL;
 
     /* Check the amount of memory is compatible with the SOC */
     if (machine->ram_size > FSL_IMX6_MMDC_SIZE) {
@@ -52,11 +51,7 @@ static void sabrelite_init(MachineState *machine)
 
     s = FSL_IMX6(object_new(TYPE_FSL_IMX6));
     object_property_add_child(OBJECT(machine), "soc", OBJECT(s), &error_fatal);
-    object_property_set_bool(OBJECT(s), true, "realized", &err);
-    if (err != NULL) {
-        error_report("%s", error_get_pretty(err));
-        exit(1);
-    }
+    object_property_set_bool(OBJECT(s), true, "realized", &error_fatal);
 
     memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR,
                                 machine->ram);
Signature · 1 line
2.21.1
#16 lore raw

PATCH v2 10/10 i386: Fix x86_cpu_load_model() error API violation

In reply to Markus Armbruster

The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call.

x86_cpu_load_model() is wrong that way. Harmless, because its @errp is always &error_abort. To fix, cut out the @errp middleman.

Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Eduardo Habkost <[email protected]>
---
 target/i386/cpu.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
target/i386/cpu.c +16 -9
index 9c256ab159..16ed95e8da 100644
@@ -5078,7 +5078,7 @@ static void x86_cpu_apply_version_props(X86CPU *cpu, X86CPUModel *model)
 
 /* Load data from X86CPUDefinition into a X86CPU object
  */
-static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model, Error **errp)
+static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)
 {
     X86CPUDefinition *def = model->cpudef;
     CPUX86State *env = &cpu->env;
@@ -5092,13 +5092,19 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model, Error **errp)
      */
 
     /* CPU models only set _minimum_ values for level/xlevel: */
-    object_property_set_uint(OBJECT(cpu), def->level, "min-level", errp);
-    object_property_set_uint(OBJECT(cpu), def->xlevel, "min-xlevel", errp);
+    object_property_set_uint(OBJECT(cpu), def->level, "min-level",
+                             &error_abort);
+    object_property_set_uint(OBJECT(cpu), def->xlevel, "min-xlevel",
+                             &error_abort);
 
-    object_property_set_int(OBJECT(cpu), def->family, "family", errp);
-    object_property_set_int(OBJECT(cpu), def->model, "model", errp);
-    object_property_set_int(OBJECT(cpu), def->stepping, "stepping", errp);
-    object_property_set_str(OBJECT(cpu), def->model_id, "model-id", errp);
+    object_property_set_int(OBJECT(cpu), def->family, "family",
+                            &error_abort);
+    object_property_set_int(OBJECT(cpu), def->model, "model",
+                            &error_abort);
+    object_property_set_int(OBJECT(cpu), def->stepping, "stepping",
+                            &error_abort);
+    object_property_set_str(OBJECT(cpu), def->model_id, "model-id",
+                            &error_abort);
     for (w = 0; w < FEATURE_WORDS; w++) {
         env->features[w] = def->features[w];
     }
@@ -5135,7 +5141,8 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model, Error **errp)
         vendor = host_vendor;
     }
 
-    object_property_set_str(OBJECT(cpu), vendor, "vendor", errp);
+    object_property_set_str(OBJECT(cpu), vendor, "vendor",
+                            &error_abort);
 
     x86_cpu_apply_version_props(cpu, model);
 }
@@ -6981,7 +6988,7 @@ static void x86_cpu_initfn(Object *obj)
     object_property_add_alias(obj, "sse4_2", obj, "sse4.2", &error_abort);
 
     if (xcc->model) {
-        x86_cpu_load_model(cpu, xcc->model, &error_abort);
+        x86_cpu_load_model(cpu, xcc->model);
     }
 }
 
Signature · 1 line
2.21.1