From: "Michael S. Tsirkin" <mst@redhat.com>
To: kvm@vger.kernel.org
Cc: avi@redhat.com
Subject: [PATCH] thinko fix: move memset to after mmap failure check
Date: Sun, 26 Apr 2009 14:46:38 +0300 [thread overview]
Message-ID: <20090426114638.GA27129@redhat.com> (raw)
By the time we've done a memset, it's too late to
check the pointer for MAP_FAILED value. Let's compare
to MAP_FAILED first.
Signed-off-by: Michael S. Tsikirn <mst@redhat.com>
---
Noticed this when reading the code.
Makes sense, does it not?
hw/device-assignment.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 1f0a1a7..0a5f850 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1087,12 +1087,12 @@ static int assigned_dev_register_msix_mmio(AssignedDevice *dev)
dev->msix_table_page = mmap(NULL, 0x1000,
PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, 0, 0);
- memset(dev->msix_table_page, 0, 0x1000);
if (dev->msix_table_page == MAP_FAILED) {
fprintf(stderr, "fail allocate msix_table_page! %s\n",
strerror(errno));
return -EFAULT;
}
+ memset(dev->msix_table_page, 0, 0x1000);
dev->mmio_index = cpu_register_io_memory(0,
msix_mmio_read, msix_mmio_write, dev);
return 0;
--
1.6.0.6
next reply other threads:[~2009-04-26 11:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-26 11:46 Michael S. Tsirkin [this message]
2009-04-26 11:52 ` [PATCH] thinko fix: move memset to after mmap failure check Avi Kivity
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=20090426114638.GA27129@redhat.com \
--to=mst@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.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