From: P J P <ppandit@redhat.com>
To: Qemu Developers <qemu-devel@nongnu.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Guoxiang Niu" <niuguoxiang@huawei.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Prasad J Pandit" <pjp@fedoraproject.org>
Subject: [Qemu-devel] [PATCH] kvm: check dev parameter when updating msi route
Date: Mon, 5 Feb 2018 11:48:49 +0530 [thread overview]
Message-ID: <20180205061849.17696-1-ppandit@redhat.com> (raw)
From: Prasad J Pandit <pjp@fedoraproject.org>
When updating message signalled interrupt(MSI) route in routine
kvm_irqchip_update_msi_route, device parameter could be null.
Add check to avoid null dereference.
Reported-by: Guoxiang Niu <niuguoxiang@huawei.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
accel/kvm/kvm-all.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index f290f487a5..cb7613d282 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -1167,7 +1167,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev)
kroute.u.msi.address_lo = (uint32_t)msg.address;
kroute.u.msi.address_hi = msg.address >> 32;
kroute.u.msi.data = le32_to_cpu(msg.data);
- if (pci_available && kvm_msi_devid_required()) {
+ if (pci_available && dev && kvm_msi_devid_required()) {
kroute.flags = KVM_MSI_VALID_DEVID;
kroute.u.msi.devid = pci_requester_id(dev);
}
@@ -1205,7 +1205,7 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg,
kroute.u.msi.address_lo = (uint32_t)msg.address;
kroute.u.msi.address_hi = msg.address >> 32;
kroute.u.msi.data = le32_to_cpu(msg.data);
- if (pci_available && kvm_msi_devid_required()) {
+ if (pci_available && dev && kvm_msi_devid_required()) {
kroute.flags = KVM_MSI_VALID_DEVID;
kroute.u.msi.devid = pci_requester_id(dev);
}
--
2.14.3
next reply other threads:[~2018-02-05 6:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-05 6:18 P J P [this message]
2018-02-05 16:57 ` [Qemu-devel] [PATCH] kvm: check dev parameter when updating msi route Paolo Bonzini
[not found] <20180202045153.1916-1-ppandit@redhat.com>
2018-02-02 19:35 ` Radim Krčmář
2018-02-05 6:17 ` P J P
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=20180205061849.17696-1-ppandit@redhat.com \
--to=ppandit@redhat.com \
--cc=niuguoxiang@huawei.com \
--cc=pbonzini@redhat.com \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
--cc=rkrcmar@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 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).