Date: Mon, 30 Sep 2024 04:45:32 GMT From: Zhenlei Huang <zlei@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: e78c315e8941 - stable/14 - etherswitch: Stop checking for failures from malloc(M_WAITOK) Message-ID: <202409300445.48U4jWiB087276@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=e78c315e8941ff39d89c45ffa5841b8028a3bbce commit e78c315e8941ff39d89c45ffa5841b8028a3bbce Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2024-09-03 10:25:27 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2024-09-30 04:44:21 +0000 etherswitch: Stop checking for failures from malloc(M_WAITOK) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45852 (cherry picked from commit 48741f4ceca71523aa1fa8da3bb78b184fad4aca) --- sys/dev/etherswitch/infineon/adm6996fc.c | 22 ++++------------------ sys/dev/etherswitch/micrel/ksz8995ma.c | 22 ++++------------------ 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/sys/dev/etherswitch/infineon/adm6996fc.c b/sys/dev/etherswitch/infineon/adm6996fc.c index 2c6c83a4388d..64f61df93db1 100644 --- a/sys/dev/etherswitch/infineon/adm6996fc.c +++ b/sys/dev/etherswitch/infineon/adm6996fc.c @@ -179,10 +179,6 @@ adm6996fc_attach_phys(struct adm6996fc_softc *sc) if_initname(sc->ifp[port], name, port); sc->miibus[port] = malloc(sizeof(device_t), M_ADM6996FC, M_WAITOK | M_ZERO); - if (sc->miibus[port] == NULL) { - err = ENOMEM; - goto failed; - } err = mii_attach(sc->sc_dev, sc->miibus[port], sc->ifp[port], adm6996fc_ifmedia_upd, adm6996fc_ifmedia_sts, \ BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0); @@ -255,12 +251,6 @@ adm6996fc_attach(device_t dev) sc->portphy = malloc(sizeof(int) * sc->numports, M_ADM6996FC, M_WAITOK | M_ZERO); - if (sc->ifp == NULL || sc->ifname == NULL || sc->miibus == NULL || - sc->portphy == NULL) { - err = ENOMEM; - goto failed; - } - /* * Attach the PHYs and complete the bus enumeration. */ @@ -281,14 +271,10 @@ adm6996fc_attach(device_t dev) return (0); failed: - if (sc->portphy != NULL) - free(sc->portphy, M_ADM6996FC); - if (sc->miibus != NULL) - free(sc->miibus, M_ADM6996FC); - if (sc->ifname != NULL) - free(sc->ifname, M_ADM6996FC); - if (sc->ifp != NULL) - free(sc->ifp, M_ADM6996FC); + free(sc->portphy, M_ADM6996FC); + free(sc->miibus, M_ADM6996FC); + free(sc->ifname, M_ADM6996FC); + free(sc->ifp, M_ADM6996FC); return (err); } diff --git a/sys/dev/etherswitch/micrel/ksz8995ma.c b/sys/dev/etherswitch/micrel/ksz8995ma.c index e512a86202c6..ccd7dbffa9e9 100644 --- a/sys/dev/etherswitch/micrel/ksz8995ma.c +++ b/sys/dev/etherswitch/micrel/ksz8995ma.c @@ -225,10 +225,6 @@ ksz8995ma_attach_phys(struct ksz8995ma_softc *sc) if_initname(sc->ifp[port], name, port); sc->miibus[port] = malloc(sizeof(device_t), M_KSZ8995MA, M_WAITOK | M_ZERO); - if (sc->miibus[port] == NULL) { - err = ENOMEM; - goto failed; - } err = mii_attach(sc->sc_dev, sc->miibus[port], sc->ifp[port], ksz8995ma_ifmedia_upd, ksz8995ma_ifmedia_sts, \ BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0); @@ -305,12 +301,6 @@ ksz8995ma_attach(device_t dev) sc->portphy = malloc(sizeof(int) * sc->numports, M_KSZ8995MA, M_WAITOK | M_ZERO); - if (sc->ifp == NULL || sc->ifname == NULL || sc->miibus == NULL || - sc->portphy == NULL) { - err = ENOMEM; - goto failed; - } - /* * Attach the PHYs and complete the bus enumeration. */ @@ -339,14 +329,10 @@ ksz8995ma_attach(device_t dev) return (0); failed: - if (sc->portphy != NULL) - free(sc->portphy, M_KSZ8995MA); - if (sc->miibus != NULL) - free(sc->miibus, M_KSZ8995MA); - if (sc->ifname != NULL) - free(sc->ifname, M_KSZ8995MA); - if (sc->ifp != NULL) - free(sc->ifp, M_KSZ8995MA); + free(sc->portphy, M_KSZ8995MA); + free(sc->miibus, M_KSZ8995MA); + free(sc->ifname, M_KSZ8995MA); + free(sc->ifp, M_KSZ8995MA); return (err); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202409300445.48U4jWiB087276>