All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH] vhost-user-input: use free(elem) instead of g_free(elem)
Date: Thu, 21 Nov 2019 13:51:09 +0000	[thread overview]
Message-ID: <20191121135109.GW439743@stefanha-x1.localdomain> (raw)
In-Reply-To: <20191120114856.GG2785116@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1315 bytes --]

On Wed, Nov 20, 2019 at 11:48:56AM +0000, Daniel P. Berrangé wrote:
> On Tue, Nov 19, 2019 at 11:16:26AM +0000, Stefan Hajnoczi wrote:
> > The virtqueue element returned by vu_queue_pop() is allocated using
> > malloc(3) by virtqueue_alloc_element().  Use the matching free(3)
> > function instead of glib's g_free().
> 
> Just as an FYI, since glib 2.46  g_malloc is hardcoded to use the
> system allocator, so it is now guaranteed that g_malloc/malloc
> and g_free/free are safely interchangable. I recently got this
> clarified in the glib docs:
> 
>   https://gitlab.gnome.org/GNOME/glib/merge_requests/1099//diffs
> 
> QEMU mandates 2.48 so we are now safe in that regard
> 
> For readability/sanity sake I'd still suggest matching functions
> but it is not a functional danger any more. Even when it was a
> risk, that risk only arose if you called GLib's API for installing
> a custom allocator callback which QEMU never did, so it was always
> a non-issue.

You are right, although QEMU did use g_mem_set_vtable().  The custom
functions still used malloc() underneath though so it would be safe
anyway:

  commit 98cf48f60aa4999f5b2808569a193a401a390e6a
  Author: Paolo Bonzini <pbonzini@redhat.com>
  Date:   Wed Sep 16 17:38:44 2015 +0200

      trace: remove malloc tracing

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2019-11-21 13:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19 11:16 [PATCH] vhost-user-input: use free(elem) instead of g_free(elem) Stefan Hajnoczi
2019-11-19 11:52 ` Marc-André Lureau
2019-11-20  9:37 ` Philippe Mathieu-Daudé
2019-11-20 11:41   ` Stefan Hajnoczi
2019-11-20 12:04     ` Michael S. Tsirkin
2019-11-20 11:48 ` Daniel P. Berrangé
2019-11-21 13:51   ` Stefan Hajnoczi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191121135109.GW439743@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.