David Hendricks has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/30765
Change subject: freebsd_spi: Use malloc() instead of alloca() ......................................................................
freebsd_spi: Use malloc() instead of alloca()
Change-Id: I03ff2bd1e20bea014333945771b560f17387ebd6 Signed-off-by: David Hendricks david.hendricks@gmail.com --- M freebsd_spi.c 1 file changed, 7 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/65/30765/1
diff --git a/freebsd_spi.c b/freebsd_spi.c index 215be20..7514912 100644 --- a/freebsd_spi.c +++ b/freebsd_spi.c @@ -145,7 +145,11 @@
/* FreeBSD uses a single buffer for rx and tx. Allocate a temporary one to avoid overwriting anything. */ size_t tmpcnt = readcnt + writecnt; - unsigned char *tmpbuf = alloca(tmpcnt); + unsigned char *tmpbuf = malloc(tmpcnt); + if (!tmpbuf) { + msg_perr("Out of memory!\n"); + return -1; + }
bzero(tmpbuf, tmpcnt); memcpy(tmpbuf, txbuf, writecnt); @@ -164,12 +168,14 @@
if (ioctl(fd, SPIGENIOC_TRANSFER, &msg) == -1) { msg_cerr("%s: ioctl: %s\n", __func__, strerror(errno)); + free(tmpbuf); return -1; }
if (rxbuf) memcpy(rxbuf, tmpbuf + writecnt, readcnt);
+ free(tmpbuf); return 0; }
David Hendricks has abandoned this change. ( https://review.coreboot.org/c/flashrom/+/30765 )
Change subject: freebsd_spi: Use malloc() instead of alloca() ......................................................................
Abandoned
Parent was abandoned