MFp4: check the return value of malloc and report an error when invalid.
This commit is contained in:
parent
6fbfd5825f
commit
14ca3cd6ff
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=162072
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user