Author: zbb Date: Wed May 17 15:58:39 2017 New Revision: 318410 URL: https://svnweb.freebsd.org/changeset/base/318410
Log: Fix broken malloc in e6000sw Malloc should always return something when M_WAITOK flag is used, but keep this code and change flag to M_NOWAIT as it is under a lock (allows for possible future change). Free ifnet structure to avoid memory leak on failure. Submitted by: Zbigniew Bodek <[email protected]> Obtained from: Semihalf Sponsored by: Stormshield Reviewed by: loos Differential revision: https://reviews.freebsd.org/D10711 Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c ============================================================================== --- head/sys/dev/etherswitch/e6000sw/e6000sw.c Wed May 17 15:57:14 2017 (r318409) +++ head/sys/dev/etherswitch/e6000sw/e6000sw.c Wed May 17 15:58:39 2017 (r318410) @@ -321,9 +321,11 @@ e6000sw_init_interface(e6000sw_softc_t * sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; - sc->ifname[port] = malloc(strlen(name) + 1, M_E6000SW, M_WAITOK); - if (sc->ifname[port] == NULL) + sc->ifname[port] = malloc(strlen(name) + 1, M_E6000SW, M_NOWAIT); + if (sc->ifname[port] == NULL) { + if_free(sc->ifp[port]); return (ENOMEM); + } memcpy(sc->ifname[port], name, strlen(name) + 1); if_initname(sc->ifp[port], sc->ifname[port], port); _______________________________________________ [email protected] mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "[email protected]"
