svn commit: r356693 - in head/stand: efi/libefi i386/libi386 libofw uboot/lib
Toomas Soome
tsoome at FreeBSD.org
Mon Jan 13 18:22:56 UTC 2020
Author: tsoome
Date: Mon Jan 13 18:22:54 2020
New Revision: 356693
URL: https://svnweb.freebsd.org/changeset/base/356693
Log:
loader: allocate properly aligned buffer for network packet
Use memalign(4, size) to ensure we have properly aligned buffer.
MFC after: 2 weeks
Modified:
head/stand/efi/libefi/efinet.c
head/stand/i386/libi386/pxe.c
head/stand/libofw/ofw_net.c
head/stand/uboot/lib/net.c
Modified: head/stand/efi/libefi/efinet.c
==============================================================================
--- head/stand/efi/libefi/efinet.c Mon Jan 13 18:22:51 2020 (r356692)
+++ head/stand/efi/libefi/efinet.c Mon Jan 13 18:22:54 2020 (r356693)
@@ -178,7 +178,7 @@ efinet_get(struct iodesc *desc, void **pkt, time_t tim
return (ret);
bufsz = net->Mode->MaxPacketSize + ETHER_HDR_LEN + ETHER_CRC_LEN;
- buf = malloc(bufsz + ETHER_ALIGN);
+ buf = memalign(4, bufsz + ETHER_ALIGN);
if (buf == NULL)
return (ret);
ptr = buf + ETHER_ALIGN;
Modified: head/stand/i386/libi386/pxe.c
==============================================================================
--- head/stand/i386/libi386/pxe.c Mon Jan 13 18:22:51 2020 (r356692)
+++ head/stand/i386/libi386/pxe.c Mon Jan 13 18:22:54 2020 (r356693)
@@ -484,7 +484,7 @@ pxe_netif_receive(void **pkt)
}
size = isr->FrameLength;
- buf = malloc(size + ETHER_ALIGN);
+ buf = memalign(4, size + ETHER_ALIGN);
if (buf == NULL) {
bio_free(isr, sizeof(*isr));
return (-1);
Modified: head/stand/libofw/ofw_net.c
==============================================================================
--- head/stand/libofw/ofw_net.c Mon Jan 13 18:22:51 2020 (r356692)
+++ head/stand/libofw/ofw_net.c Mon Jan 13 18:22:54 2020 (r356693)
@@ -142,7 +142,7 @@ ofwn_get(struct iodesc *desc, void **pkt, time_t timeo
* a small shortcut here.
*/
len = ETHER_MAX_LEN;
- buf = malloc(len + ETHER_ALIGN);
+ buf = memalign(4, len + ETHER_ALIGN);
if (buf == NULL)
return (-1);
ptr = buf + ETHER_ALIGN;
Modified: head/stand/uboot/lib/net.c
==============================================================================
--- head/stand/uboot/lib/net.c Mon Jan 13 18:22:51 2020 (r356692)
+++ head/stand/uboot/lib/net.c Mon Jan 13 18:22:54 2020 (r356693)
@@ -302,7 +302,7 @@ net_get(struct iodesc *desc, void **pkt, time_t timeou
#endif
if (rlen > 0) {
- buf = malloc(rlen + ETHER_ALIGN);
+ buf = memalign(4, rlen + ETHER_ALIGN);
if (buf == NULL)
return (-1);
memcpy(buf + ETHER_ALIGN, sc->sc_rxbuf, rlen);
More information about the svn-src-all
mailing list