qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: Lukas Straub <lukasstraub2@web.de>
Cc: Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Huth <thuth@redhat.com>, Li Zhang <zhlcindy@gmail.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [PATCH 4/5] chardev/char.c: Always pass id to chardev_new
Date: Mon, 22 Mar 2021 12:33:01 +0400	[thread overview]
Message-ID: <CAJ+F1CK81Se080SJSm2O11TxMzTzuOVOHqgphW3D615y-6rvjw@mail.gmail.com> (raw)
In-Reply-To: <a378d9426980c97a5cbbf2e72815f366c158ef71.1616368879.git.lukasstraub2@web.de>

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

On Mon, Mar 22, 2021 at 3:31 AM Lukas Straub <lukasstraub2@web.de> wrote:

> Always pass the id to chardev_new, since it is needed to register
> the yank instance for the chardev. Also, after checking that
> nothing calls chardev_new with id=NULL, assert() that id!=NULL.
>
> This fixes a crash when using chardev-change to change a chardev
> to chardev-socket, which attempts to register a yank instance.
> This in turn tries to dereference the NULL-pointer.
>
> Signed-off-by: Lukas Straub <lukasstraub2@web.de>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

---
>  chardev/char.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/chardev/char.c b/chardev/char.c
> index 1584865027..ad416c0714 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -964,6 +964,7 @@ static Chardev *chardev_new(const char *id, const char
> *typename,
>      bool be_opened = true;
>
>      assert(g_str_has_prefix(typename, "chardev-"));
> +    assert(id);
>
>      obj = object_new(typename);
>      chr = CHARDEV(obj);
> @@ -1092,12 +1093,11 @@ ChardevReturn *qmp_chardev_change(const char *id,
> ChardevBackend *backend,
>          return NULL;
>      }
>
> -    chr_new = chardev_new(NULL, object_class_get_name(OBJECT_CLASS(cc)),
> +    chr_new = chardev_new(id, object_class_get_name(OBJECT_CLASS(cc)),
>                            backend, chr->gcontext, errp);
>      if (!chr_new) {
>          return NULL;
>      }
> -    chr_new->label = g_strdup(id);
>
>      if (chr->be_open && !chr_new->be_open) {
>          qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
> --
> 2.30.2
>
>

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 2536 bytes --]

  reply	other threads:[~2021-03-22  8:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-21 23:31 [PATCH 0/5] yank: Add chardev tests and fixes Lukas Straub
2021-03-21 23:31 ` [PATCH 1/5] tests: Use the normal yank code instead of stubs in relevant tests Lukas Straub
2021-03-22  5:20   ` Thomas Huth
2021-03-22  7:35     ` Lukas Straub
2021-03-22 16:00       ` Thomas Huth
2021-03-22 17:48         ` Lukas Straub
2021-03-23  4:46           ` Thomas Huth
2021-03-23 14:54             ` Lukas Straub
2021-03-21 23:31 ` [PATCH 2/5] tests: Add tests for yank with the chardev-change Lukas Straub
2021-03-22  8:04   ` Marc-André Lureau
2021-03-21 23:31 ` [PATCH 3/5] chardev/char.c: Move object_property_try_add_child out of chardev_new Lukas Straub
2021-03-22  8:42   ` Marc-André Lureau
2021-03-21 23:31 ` [PATCH 4/5] chardev/char.c: Always pass id to chardev_new Lukas Straub
2021-03-22  8:33   ` Marc-André Lureau [this message]
2021-03-22 10:32   ` Li Zhang
2021-03-21 23:32 ` [PATCH 5/5] chardev: Fix yank with the chardev-change case Lukas Straub
2021-03-22  8:32   ` Marc-André Lureau

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=CAJ+F1CK81Se080SJSm2O11TxMzTzuOVOHqgphW3D615y-6rvjw@mail.gmail.com \
    --to=marcandre.lureau@gmail.com \
    --cc=lukasstraub2@web.de \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=zhlcindy@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).