svn commit: r336191 - stable/11/usr.sbin/bhyve
Marcelo Araujo
araujo at FreeBSD.org
Wed Jul 11 07:22:07 UTC 2018
Author: araujo
Date: Wed Jul 11 07:22:05 2018
New Revision: 336191
URL: https://svnweb.freebsd.org/changeset/base/336191
Log:
MFC r335027, r335050
r335027:
When this code was introduced at r300829 the author forgot to add
the BSD license header that is the same as in its C header file.
Sponsored by: iXsystems Inc.
r335050:
While I was investigating CID 1194192 related with a resource leak on mrp memory
allocation, I could identify that actually we use this pointer on pci_emul.c as
well as on vga.c source file.
I have reworked the logic here to make it more readable and also add a warn to
explicit show the function where the memory allocation error could happen,
also sort headers.
Also CID 1194192 was marked as "Intentional".
Obtained from: TrueOS
Sponsored by: iXsystems Inc.
Modified:
stable/11/usr.sbin/bhyve/bhyvegc.c
stable/11/usr.sbin/bhyve/mem.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/usr.sbin/bhyve/bhyvegc.c
==============================================================================
--- stable/11/usr.sbin/bhyve/bhyvegc.c Wed Jul 11 07:19:42 2018 (r336190)
+++ stable/11/usr.sbin/bhyve/bhyvegc.c Wed Jul 11 07:22:05 2018 (r336191)
@@ -1,3 +1,31 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2015 Tycho Nightingale <tycho.nightingale at pluribusnetworks.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
Modified: stable/11/usr.sbin/bhyve/mem.c
==============================================================================
--- stable/11/usr.sbin/bhyve/mem.c Wed Jul 11 07:19:42 2018 (r336190)
+++ stable/11/usr.sbin/bhyve/mem.c Wed Jul 11 07:22:05 2018 (r336191)
@@ -38,15 +38,16 @@
__FBSDID("$FreeBSD$");
#include <sys/types.h>
-#include <sys/tree.h>
#include <sys/errno.h>
+#include <sys/tree.h>
#include <machine/vmm.h>
#include <machine/vmm_instruction_emul.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <assert.h>
+#include <err.h>
#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
#include "mem.h"
@@ -230,8 +231,11 @@ register_mem_int(struct mmio_rb_tree *rbt, struct mem_
err = 0;
mrp = malloc(sizeof(struct mmio_rb_range));
-
- if (mrp != NULL) {
+ if (mrp == NULL) {
+ warn("%s: couldn't allocate memory for mrp\n",
+ __func__);
+ err = ENOMEM;
+ } else {
mrp->mr_param = *memp;
mrp->mr_base = memp->base;
mrp->mr_end = memp->base + memp->size - 1;
@@ -242,8 +246,7 @@ register_mem_int(struct mmio_rb_tree *rbt, struct mem_
assert(perror == 0);
if (err)
free(mrp);
- } else
- err = ENOMEM;
+ }
return (err);
}
More information about the svn-src-stable-11
mailing list