From nobody Thu Oct 07 03:37:42 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2190317E15EE; Thu, 7 Oct 2021 03:37:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HPxpv0LKCz4vBF; Thu, 7 Oct 2021 03:37:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E030B46E1; Thu, 7 Oct 2021 03:37:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1973bgVY073901; Thu, 7 Oct 2021 03:37:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1973bgRH073900; Thu, 7 Oct 2021 03:37:42 GMT (envelope-from git) Date: Thu, 7 Oct 2021 03:37:42 GMT Message-Id: <202110070337.1973bgRH073900@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 000aad3d093a - stable/12 - loader: allocate properly aligned buffer for network packet List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 000aad3d093a376bb1104a284b4102149db43155 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=000aad3d093a376bb1104a284b4102149db43155 commit 000aad3d093a376bb1104a284b4102149db43155 Author: Toomas Soome AuthorDate: 2020-01-13 18:22:54 +0000 Commit: Kyle Evans CommitDate: 2021-10-07 03:36:34 +0000 loader: allocate properly aligned buffer for network packet Use memalign(4, size) to ensure we have properly aligned buffer. (cherry picked from commit 659bf32dfc595b6cd6aeda7f05cb57872c64d2d1) --- stand/efi/libefi/efinet.c | 2 +- stand/i386/libi386/pxe.c | 2 +- stand/libofw/ofw_net.c | 2 +- stand/uboot/lib/net.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stand/efi/libefi/efinet.c b/stand/efi/libefi/efinet.c index 418790524e4a..989b2efdaac2 100644 --- a/stand/efi/libefi/efinet.c +++ b/stand/efi/libefi/efinet.c @@ -178,7 +178,7 @@ efinet_get(struct iodesc *desc, void **pkt, time_t timeout) 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; diff --git a/stand/i386/libi386/pxe.c b/stand/i386/libi386/pxe.c index e80a1961e191..e94c63878284 100644 --- a/stand/i386/libi386/pxe.c +++ b/stand/i386/libi386/pxe.c @@ -501,7 +501,7 @@ pxe_netif_receive_isr(t_PXENV_UNDI_ISR *isr, void **pkt, ssize_t *retsize) * multiple GET_NEXT calls. */ size = isr->FrameLength; - buf = malloc(size + ETHER_ALIGN); + buf = memalign(4, size + ETHER_ALIGN); if (buf == NULL) return (ENOMEM); diff --git a/stand/libofw/ofw_net.c b/stand/libofw/ofw_net.c index 14494ecc2b2e..a037c3defaf5 100644 --- a/stand/libofw/ofw_net.c +++ b/stand/libofw/ofw_net.c @@ -142,7 +142,7 @@ ofwn_get(struct iodesc *desc, void **pkt, time_t timeout) * 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; diff --git a/stand/uboot/lib/net.c b/stand/uboot/lib/net.c index 81b8c5bc9f5b..3d0ba5fdc6d3 100644 --- a/stand/uboot/lib/net.c +++ b/stand/uboot/lib/net.c @@ -302,7 +302,7 @@ net_get(struct iodesc *desc, void **pkt, time_t timeout) #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);