summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2005-03-29 01:48:21 +0000
committersam <sam@FreeBSD.org>2005-03-29 01:48:21 +0000
commited1d4fbad5c27213cf394c7b62f627ffc170d661 (patch)
tree7f52d246cb2be4af06a0ffdab4ab90010b74db52
parentfd379eb29af4e0638ef7b2c1ada42ae654aa65b6 (diff)
downloadFreeBSD-src-ed1d4fbad5c27213cf394c7b62f627ffc170d661.zip
FreeBSD-src-ed1d4fbad5c27213cf394c7b62f627ffc170d661.tar.gz
handle malloc failure and don't proceed when the bios call to
get parameters passed to malloc fails Noticed by: Coverity Prevent analysis tool (malloc failure)
-rw-r--r--sys/i386/i386/bios.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/i386/i386/bios.c b/sys/i386/i386/bios.c
index ca434cb..332bd6c 100644
--- a/sys/i386/i386/bios.c
+++ b/sys/i386/i386/bios.c
@@ -568,14 +568,20 @@ pnpbios_identify(driver_t *driver, device_t parent)
args.seg.data.limit = 0xffff;
args.entry = pt->pmentryoffset;
- if ((error = bios16(&args, PNP_COUNT_DEVNODES, &ndevs, &bigdev)) || (args.r.eax & 0xff))
+ if ((error = bios16(&args, PNP_COUNT_DEVNODES, &ndevs, &bigdev)) || (args.r.eax & 0xff)) {
printf("pnpbios: error %d/%x getting device count/size limit\n", error, args.r.eax);
+ return;
+ }
ndevs &= 0xff; /* clear high byte garbage */
if (bootverbose)
printf("pnpbios: %d devices, largest %d bytes\n", ndevs, bigdev);
devnodebuf = malloc(bigdev + (sizeof(struct pnp_sysdevargs) - sizeof(struct pnp_sysdev)),
M_DEVBUF, M_NOWAIT);
+ if (devnodebuf == NULL) {
+ printf("pnpbios: cannot allocate memory, bailing\n");
+ return;
+ }
pda = (struct pnp_sysdevargs *)devnodebuf;
pd = &pda->node;
OpenPOWER on IntegriCloud