summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2006-09-06 19:46:02 +0000
committerimp <imp@FreeBSD.org>2006-09-06 19:46:02 +0000
commit50aef091890514c5738156130ba23bdfb2592788 (patch)
treed60d97145ddf394e4ee67f39eabe9ca0a8e39f4b /sys/dev
parentb095262f189d46a0e46843ff01c0f2049119811f (diff)
downloadFreeBSD-src-50aef091890514c5738156130ba23bdfb2592788.zip
FreeBSD-src-50aef091890514c5738156130ba23bdfb2592788.tar.gz
MFp4: check the return value of malloc and report an error when invalid.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/iicbus/iic.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/dev/iicbus/iic.c b/sys/dev/iicbus/iic.c
index b50d2e0..038a8e8 100644
--- a/sys/dev/iicbus/iic.c
+++ b/sys/dev/iicbus/iic.c
@@ -282,6 +282,10 @@ iicioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *t
break;
}
buf = malloc((unsigned long)s->count, M_TEMP, M_WAITOK);
+ if (buf == NULL) {
+ error = ENOMEM;
+ break;
+ }
error = copyin(s->buf, buf, s->count);
if (error)
break;
@@ -294,6 +298,10 @@ iicioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *t
break;
}
buf = malloc((unsigned long)s->count, M_TEMP, M_WAITOK);
+ if (buf == NULL) {
+ error = ENOMEM;
+ break;
+ }
error = iicbus_read(parent, buf, s->count, &count, s->last, 10);
if (error)
break;
@@ -302,7 +310,15 @@ iicioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *t
case I2CRDWR:
buf = malloc(sizeof(*d->msgs) * d->nmsgs, M_TEMP, M_WAITOK);
+ if (buf == NULL) {
+ error = ENOMEM;
+ break;
+ }
usrbufs = malloc(sizeof(void *) * d->nmsgs, M_TEMP, M_ZERO | M_WAITOK);
+ if (usrbufs == NULL) {
+ error = ENOMEM;
+ break;
+ }
error = copyin(d->msgs, buf, sizeof(*d->msgs) * d->nmsgs);
if (error)
break;
OpenPOWER on IntegriCloud