summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2013-03-06 06:24:09 +0000
committergrehan <grehan@FreeBSD.org>2013-03-06 06:24:09 +0000
commitf5b9af89495d41ff3e3095a9dae2f05d8504e31c (patch)
tree5704fdeecf87d639adc2f868f00688ad26fceafd /usr.sbin
parent1e16d8b6f0b524e7ca27ef6d5ceb4dedd8d1a061 (diff)
downloadFreeBSD-src-f5b9af89495d41ff3e3095a9dae2f05d8504e31c.zip
FreeBSD-src-f5b9af89495d41ff3e3095a9dae2f05d8504e31c.tar.gz
Reorder code to avoid the stat buffer being used uninitialized.
Obtained from: NetApp
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bhyve/acpi.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c
index cabe75e..f9504f8 100644
--- a/usr.sbin/bhyve/acpi.c
+++ b/usr.sbin/bhyve/acpi.c
@@ -687,12 +687,16 @@ basl_load(int fd, uint64_t off)
int err;
err = 0;
- gaddr = paddr_guest2host(basl_acpi_base + off, sb.st_size);
- if (gaddr != NULL) {
- if (fstat(fd, &sb) < 0 || read(fd, gaddr, sb.st_size) < 0)
- err = errno;
- } else
- err = EFAULT;
+ if (fstat(fd, &sb) < 0) {
+ err = errno;
+ } else {
+ gaddr = paddr_guest2host(basl_acpi_base + off, sb.st_size);
+ if (gaddr != NULL) {
+ if (read(fd, gaddr, sb.st_size) < 0)
+ err = errno;
+ } else
+ err = EFAULT;
+ }
return (err);
}
OpenPOWER on IntegriCloud