qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bernhard Beschow <shentey@gmail.com>
To: qemu-devel@nongnu.org, Dmitry Frolov <frolov@swemel.ru>,
	pbonzini@redhat.com, Peter Maydell <peter.maydell@linaro.org>
Cc: sdl.qemu@linuxtesting.org
Subject: Re: [PATCH] hw/i386: fix NULL-dereference
Date: Thu, 07 Nov 2024 09:19:05 +0000	[thread overview]
Message-ID: <384458DB-F470-44E9-8C16-7D35DDDE4CBF@gmail.com> (raw)
In-Reply-To: <20241107070415.694662-2-frolov@swemel.ru>



Am 7. November 2024 07:04:10 UTC schrieb Dmitry Frolov <frolov@swemel.ru>:
>If pcmc->pci_enabled is false, pcms->pcibus is NULL and is passed
>to pc_nic_init() where it is being dereferenced.
>
>Found making check with enabled sanitizers.
>
>Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
>---
> hw/i386/pc_piix.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>index 2bf6865d40..2a92d2dbb7 100644
>--- a/hw/i386/pc_piix.c
>+++ b/hw/i386/pc_piix.c
>@@ -313,9 +313,9 @@ static void pc_init1(MachineState *machine, const char *pci_type)
>     /* init basic PC hardware */
>     pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc,
>                          !MACHINE_CLASS(pcmc)->no_floppy, 0x4);
>-
>-    pc_nic_init(pcmc, isa_bus, pcms->pcibus);
>-
>+    if (pcmc->pci_enabled) {
>+        pc_nic_init(pcmc, isa_bus, pcms->pcibus);
>+    }

Since pc_nic_init() is passed both an ISA and a PCI bus I think the NULL dereference should be fixed there. Moreover, if pc_nic_init() is only invoked when there is a PCI bus, the "isapc" machine won't have a nic at all.

How is this patch related to https://patchew.org/QEMU/20241105171813.3031969-1-peter.maydell@linaro.org ? That is, do we need both patches to really fix the issue?

Best regards,
Bernhard

> #ifdef CONFIG_IDE_ISA
>     if (!pcmc->pci_enabled) {
>         DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];


  parent reply	other threads:[~2024-11-07  9:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07  7:04 [PATCH] hw/i386: fix NULL-dereference Dmitry Frolov
2024-11-07  9:04 ` Zhao Liu
2024-11-07 19:10   ` Bernhard Beschow
2024-11-07  9:19 ` Bernhard Beschow [this message]
2024-11-07 19:09   ` Bernhard Beschow

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=384458DB-F470-44E9-8C16-7D35DDDE4CBF@gmail.com \
    --to=shentey@gmail.com \
    --cc=frolov@swemel.ru \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sdl.qemu@linuxtesting.org \
    /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).