Date: Wed, 6 Sep 2006 19:40:31 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 105732 for review Message-ID: <200609061940.k86JeVQQ049447@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=105732 Change 105732 by imp@imp_lighthouse on 2006/09/06 19:39:43 Check malloc for success/failure. Affected files ... .. //depot/projects/arm/src/sys/dev/iicbus/iic.c#5 edit Differences ... ==== //depot/projects/arm/src/sys/dev/iicbus/iic.c#5 (text+ko) ==== @@ -282,6 +282,10 @@ 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 @@ 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 @@ 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609061940.k86JeVQQ049447>