- * [PULL 1/3] ui/keymaps: Avoid trace crash and improve error messages
  2025-09-01 11:19 [PULL 0/3] Error reporting patches for 2025-09-01 Markus Armbruster
@ 2025-09-01 11:19 ` Markus Armbruster
  2025-09-01 11:19 ` [PULL 2/3] i386/kvm/vmsr_energy: Plug memory leak on failure to connect socket Markus Armbruster
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2025-09-01 11:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: richard.henderson, Marc-André Lureau,
	Philippe Mathieu-Daudé
parse_keyboard_layout() passes a possibly null @filename to
trace_keymap_parse().  Trace backend log then formats it with %s,
which crashes on some systems.
Fix by moving the null check before the trace_keymap_parse().
While there, improve the error messages a bit.
Fixes: d3b787fa7dde (keymaps: add tracing)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20250723131504.1482657-1-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 ui/keymaps.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/ui/keymaps.c b/ui/keymaps.c
index 6ceaa97085..2359dbfe7e 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -86,19 +86,25 @@ static int parse_keyboard_layout(kbd_layout_t *k,
                                  const name2keysym_t *table,
                                  const char *language, Error **errp)
 {
+    g_autofree char *filename = NULL;
     int ret;
     FILE *f;
-    char * filename;
     char line[1024];
     char keyname[64];
     int len;
 
     filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
+    if (!filename) {
+        error_setg(errp, "could not find keymap file for language '%s'",
+                   language);
+        return -1;
+    }
+
     trace_keymap_parse(filename);
-    f = filename ? fopen(filename, "r") : NULL;
-    g_free(filename);
+
+    f = fopen(filename, "r");
     if (!f) {
-        error_setg(errp, "could not read keymap file: '%s'", language);
+        error_setg_file_open(errp, errno, filename);
         return -1;
     }
 
-- 
2.49.0
^ permalink raw reply related	[flat|nested] 5+ messages in thread
- * [PULL 2/3] i386/kvm/vmsr_energy: Plug memory leak on failure to connect socket
  2025-09-01 11:19 [PULL 0/3] Error reporting patches for 2025-09-01 Markus Armbruster
  2025-09-01 11:19 ` [PULL 1/3] ui/keymaps: Avoid trace crash and improve error messages Markus Armbruster
@ 2025-09-01 11:19 ` Markus Armbruster
  2025-09-01 11:19 ` [PULL 3/3] vfio scsi ui: Error-check qio_channel_socket_connect_sync() the same way Markus Armbruster
  2025-09-02 13:47 ` [PULL 0/3] Error reporting patches for 2025-09-01 Richard Henderson
  3 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2025-09-01 11:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson, Zhao Liu
vmsr_open_socket() leaks the Error set by
qio_channel_socket_connect_sync().  Plug the leak by not creating the
Error.
Fixes: 0418f90809ae (Add support for RAPL MSRs in KVM/Qemu)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20250723133257.1497640-2-armbru@redhat.com>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
---
 target/i386/kvm/vmsr_energy.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/target/i386/kvm/vmsr_energy.c b/target/i386/kvm/vmsr_energy.c
index 58ce3df53a..890322ae37 100644
--- a/target/i386/kvm/vmsr_energy.c
+++ b/target/i386/kvm/vmsr_energy.c
@@ -57,13 +57,9 @@ QIOChannelSocket *vmsr_open_socket(const char *path)
     };
 
     QIOChannelSocket *sioc = qio_channel_socket_new();
-    Error *local_err = NULL;
 
     qio_channel_set_name(QIO_CHANNEL(sioc), "vmsr-helper");
-    qio_channel_socket_connect_sync(sioc,
-                                    &saddr,
-                                    &local_err);
-    if (local_err) {
+    if (qio_channel_socket_connect_sync(sioc, &saddr, NULL) < 0) {
         /* Close socket. */
         qio_channel_close(QIO_CHANNEL(sioc), NULL);
         object_unref(OBJECT(sioc));
-- 
2.49.0
^ permalink raw reply related	[flat|nested] 5+ messages in thread
- * [PULL 3/3] vfio scsi ui: Error-check qio_channel_socket_connect_sync() the same way
  2025-09-01 11:19 [PULL 0/3] Error reporting patches for 2025-09-01 Markus Armbruster
  2025-09-01 11:19 ` [PULL 1/3] ui/keymaps: Avoid trace crash and improve error messages Markus Armbruster
  2025-09-01 11:19 ` [PULL 2/3] i386/kvm/vmsr_energy: Plug memory leak on failure to connect socket Markus Armbruster
@ 2025-09-01 11:19 ` Markus Armbruster
  2025-09-02 13:47 ` [PULL 0/3] Error reporting patches for 2025-09-01 Richard Henderson
  3 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2025-09-01 11:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson, Zhao Liu
qio_channel_socket_connect_sync() returns 0 on success, and -1 on
failure, with errp set.  Some callers check the return value, and some
check whether errp was set.
For consistency, always check the return value, and always check it's
negative.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20250723133257.1497640-3-armbru@redhat.com>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
---
 hw/vfio-user/proxy.c     | 2 +-
 scsi/pr-manager-helper.c | 9 ++-------
 ui/input-barrier.c       | 5 +----
 3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c
index 2275d3fe39..2c03d49f97 100644
--- a/hw/vfio-user/proxy.c
+++ b/hw/vfio-user/proxy.c
@@ -885,7 +885,7 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *addr, Error **errp)
 
     sioc = qio_channel_socket_new();
     ioc = QIO_CHANNEL(sioc);
-    if (qio_channel_socket_connect_sync(sioc, addr, errp)) {
+    if (qio_channel_socket_connect_sync(sioc, addr, errp) < 0) {
         object_unref(OBJECT(ioc));
         return NULL;
     }
diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c
index 6b86f01b01..aea751fb04 100644
--- a/scsi/pr-manager-helper.c
+++ b/scsi/pr-manager-helper.c
@@ -105,20 +105,15 @@ static int pr_manager_helper_initialize(PRManagerHelper *pr_mgr,
         .u.q_unix.path = path
     };
     QIOChannelSocket *sioc = qio_channel_socket_new();
-    Error *local_err = NULL;
-
     uint32_t flags;
     int r;
 
     assert(!pr_mgr->ioc);
     qio_channel_set_name(QIO_CHANNEL(sioc), "pr-manager-helper");
-    qio_channel_socket_connect_sync(sioc,
-                                    &saddr,
-                                    &local_err);
+    r = qio_channel_socket_connect_sync(sioc, &saddr, errp);
     g_free(path);
-    if (local_err) {
+    if (r < 0) {
         object_unref(OBJECT(sioc));
-        error_propagate(errp, local_err);
         return -ENOTCONN;
     }
 
diff --git a/ui/input-barrier.c b/ui/input-barrier.c
index 9793258aac..0a2198ca50 100644
--- a/ui/input-barrier.c
+++ b/ui/input-barrier.c
@@ -490,7 +490,6 @@ static gboolean input_barrier_event(QIOChannel *ioc G_GNUC_UNUSED,
 static void input_barrier_complete(UserCreatable *uc, Error **errp)
 {
     InputBarrier *ib = INPUT_BARRIER(uc);
-    Error *local_err = NULL;
 
     if (!ib->name) {
         error_setg(errp, QERR_MISSING_PARAMETER, "name");
@@ -506,9 +505,7 @@ static void input_barrier_complete(UserCreatable *uc, Error **errp)
     ib->sioc = qio_channel_socket_new();
     qio_channel_set_name(QIO_CHANNEL(ib->sioc), "barrier-client");
 
-    qio_channel_socket_connect_sync(ib->sioc, &ib->saddr, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (qio_channel_socket_connect_sync(ib->sioc, &ib->saddr, errp) < 0) {
         return;
     }
 
-- 
2.49.0
^ permalink raw reply related	[flat|nested] 5+ messages in thread
- * Re: [PULL 0/3] Error reporting patches for 2025-09-01
  2025-09-01 11:19 [PULL 0/3] Error reporting patches for 2025-09-01 Markus Armbruster
                   ` (2 preceding siblings ...)
  2025-09-01 11:19 ` [PULL 3/3] vfio scsi ui: Error-check qio_channel_socket_connect_sync() the same way Markus Armbruster
@ 2025-09-02 13:47 ` Richard Henderson
  3 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2025-09-02 13:47 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel
On 9/1/25 21:19, Markus Armbruster wrote:
> The following changes since commit 91589bcd9fee0e66b241d04e5f37cd4f218187a2:
> 
>    Merge tag 'for-upstream' ofhttps://gitlab.com/bonzini/qemu into staging (2025-08-31 09:08:09 +1000)
> 
> are available in the Git repository at:
> 
>    https://repo.or.cz/qemu/armbru.git tags/pull-error-2025-09-01
> 
> for you to fetch changes up to ec14a3de622ae30a8afa78b6f564bc743b753ee1:
> 
>    vfio scsi ui: Error-check qio_channel_socket_connect_sync() the same way (2025-09-01 13:11:13 +0200)
> 
> ----------------------------------------------------------------
> Error reporting patches for 2025-09-01
Applied, thanks.  Please update https://wiki.qemu.org/ChangeLog/10.2 as appropriate.
r~
^ permalink raw reply	[flat|nested] 5+ messages in thread