diff options
author | marius <marius@FreeBSD.org> | 2005-05-19 15:23:17 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2005-05-19 15:23:17 +0000 |
commit | 1909936cb97a59b693c9e25ec37da6f0948a1ec3 (patch) | |
tree | a91685ad9362052fe9eae547aea8f8498dc50d26 /sys/dev/ofw | |
parent | 8520dd8df2573d62da4900787cfd59ccb123f8d8 (diff) | |
download | FreeBSD-src-1909936cb97a59b693c9e25ec37da6f0948a1ec3.zip FreeBSD-src-1909936cb97a59b693c9e25ec37da6f0948a1ec3.tar.gz |
Sync with openfirm(4) and check the return value of malloc() although
this isn't exactly necessary with M_WAITOK.
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r-- | sys/dev/ofw/openpromio.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sys/dev/ofw/openpromio.c b/sys/dev/ofw/openpromio.c index 07a0791..ca6aba7 100644 --- a/sys/dev/ofw/openpromio.c +++ b/sys/dev/ofw/openpromio.c @@ -101,6 +101,7 @@ openprom_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, char *buf; int error; + prop = buf = NULL; error = 0; oprom = *(void **)data; switch (cmd) { @@ -142,10 +143,18 @@ openprom_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, break; } prop = malloc(len, M_TEMP, M_WAITOK | M_ZERO); + if (prop == NULL) { + error = ENOMEM; + break; + } error = copyinstr(&oprom->oprom_array, prop, len, &done); if (error != 0) break; buf = malloc(OPROMMAXPARAM, M_TEMP, M_WAITOK | M_ZERO); + if (buf == NULL) { + error = ENOMEM; + break; + } node = openprom_node; switch (cmd) { case OPROMGETPROP: @@ -169,13 +178,17 @@ openprom_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, proplen + 1); } else error = EINVAL; - free(prop, M_TEMP); - free(buf, M_TEMP); break; default: error = ENOIOCTL; break; } + + if (prop != NULL) + free(prop, M_TEMP); + if (buf != NULL) + free(buf, M_TEMP); + return (error); } |