Browse Source

i386/kvm/vmsr_energy: Plug memory leak on failure to connect socket

vmsr_open_socket() leaks the Error set by
qio_channel_socket_connect_sync().  Plug the leak by not creating the
Error.

Fixes: 0418f90809 (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>
pull/299/head
Markus Armbruster 1 year ago
parent
commit
b2e4534a2c
  1. 6
      target/i386/kvm/vmsr_energy.c

6
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));

Loading…
Cancel
Save