From owner-svn-src-all@freebsd.org Wed Jan 24 21:33:19 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 97A2AEC731D; Wed, 24 Jan 2018 21:33:19 +0000 (UTC) (envelope-from mizhka@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4537579480; Wed, 24 Jan 2018 21:33:19 +0000 (UTC) (envelope-from mizhka@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4024E23311; Wed, 24 Jan 2018 21:33:19 +0000 (UTC) (envelope-from mizhka@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0OLXJDU078289; Wed, 24 Jan 2018 21:33:19 GMT (envelope-from mizhka@FreeBSD.org) Received: (from mizhka@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0OLXIOe078281; Wed, 24 Jan 2018 21:33:18 GMT (envelope-from mizhka@FreeBSD.org) Message-Id: <201801242133.w0OLXIOe078281@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mizhka set sender to mizhka@FreeBSD.org using -f From: Michael Zhilin Date: Wed, 24 Jan 2018 21:33:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328377 - in head/sys/dev/etherswitch: arswitch e6000sw infineon ip17x micrel mtkswitch rtl8366 ukswitch X-SVN-Group: head X-SVN-Commit-Author: mizhka X-SVN-Commit-Paths: in head/sys/dev/etherswitch: arswitch e6000sw infineon ip17x micrel mtkswitch rtl8366 ukswitch X-SVN-Commit-Revision: 328377 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 21:33:19 -0000 Author: mizhka Date: Wed Jan 24 21:33:18 2018 New Revision: 328377 URL: https://svnweb.freebsd.org/changeset/base/328377 Log: [etherswitch] check if_alloc returns NULL This patch is cosmetic. It checks if allocation of ifnet structure failed. It's better to have this check rather than assume positive scenario. Submitted by: Dmitry Luhtionov Reported by: Dmitry Luhtionov Modified: head/sys/dev/etherswitch/arswitch/arswitch.c head/sys/dev/etherswitch/e6000sw/e6060sw.c head/sys/dev/etherswitch/infineon/adm6996fc.c head/sys/dev/etherswitch/ip17x/ip17x.c head/sys/dev/etherswitch/micrel/ksz8995ma.c head/sys/dev/etherswitch/mtkswitch/mtkswitch.c head/sys/dev/etherswitch/rtl8366/rtl8366rb.c head/sys/dev/etherswitch/ukswitch/ukswitch.c Modified: head/sys/dev/etherswitch/arswitch/arswitch.c ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitch.c Wed Jan 24 21:26:01 2018 (r328376) +++ head/sys/dev/etherswitch/arswitch/arswitch.c Wed Jan 24 21:33:18 2018 (r328377) @@ -177,6 +177,12 @@ arswitch_attach_phys(struct arswitch_softc *sc) snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev)); for (phy = 0; phy < sc->numphys; phy++) { sc->ifp[phy] = if_alloc(IFT_ETHER); + if (sc->ifp[phy] == NULL) { + device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); + err = ENOMEM; + break; + } + sc->ifp[phy]->if_softc = sc; sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; Modified: head/sys/dev/etherswitch/e6000sw/e6060sw.c ============================================================================== --- head/sys/dev/etherswitch/e6000sw/e6060sw.c Wed Jan 24 21:26:01 2018 (r328376) +++ head/sys/dev/etherswitch/e6000sw/e6060sw.c Wed Jan 24 21:33:18 2018 (r328377) @@ -218,6 +218,12 @@ e6060sw_attach_phys(struct e6060sw_softc *sc) sc->ifpport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); + if (sc->ifp[port] == NULL) { + device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); + err = ENOMEM; + break; + } + sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; Modified: head/sys/dev/etherswitch/infineon/adm6996fc.c ============================================================================== --- head/sys/dev/etherswitch/infineon/adm6996fc.c Wed Jan 24 21:26:01 2018 (r328376) +++ head/sys/dev/etherswitch/infineon/adm6996fc.c Wed Jan 24 21:33:18 2018 (r328377) @@ -175,6 +175,12 @@ adm6996fc_attach_phys(struct adm6996fc_softc *sc) sc->ifpport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); + if (sc->ifp[port] == NULL) { + device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); + err = ENOMEM; + break; + } + sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; Modified: head/sys/dev/etherswitch/ip17x/ip17x.c ============================================================================== --- head/sys/dev/etherswitch/ip17x/ip17x.c Wed Jan 24 21:26:01 2018 (r328376) +++ head/sys/dev/etherswitch/ip17x/ip17x.c Wed Jan 24 21:33:18 2018 (r328377) @@ -174,6 +174,12 @@ ip17x_attach_phys(struct ip17x_softc *sc) sc->phyport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); + if (sc->ifp[port] == NULL) { + device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); + err = ENOMEM; + break; + } + sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; Modified: head/sys/dev/etherswitch/micrel/ksz8995ma.c ============================================================================== --- head/sys/dev/etherswitch/micrel/ksz8995ma.c Wed Jan 24 21:26:01 2018 (r328376) +++ head/sys/dev/etherswitch/micrel/ksz8995ma.c Wed Jan 24 21:33:18 2018 (r328377) @@ -221,6 +221,12 @@ ksz8995ma_attach_phys(struct ksz8995ma_softc *sc) sc->ifpport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); + if (sc->ifp[port] == NULL) { + device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); + err = ENOMEM; + break; + } + sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; Modified: head/sys/dev/etherswitch/mtkswitch/mtkswitch.c ============================================================================== --- head/sys/dev/etherswitch/mtkswitch/mtkswitch.c Wed Jan 24 21:26:01 2018 (r328376) +++ head/sys/dev/etherswitch/mtkswitch/mtkswitch.c Wed Jan 24 21:33:18 2018 (r328377) @@ -122,6 +122,12 @@ mtkswitch_attach_phys(struct mtkswitch_softc *sc) continue; } sc->ifp[phy] = if_alloc(IFT_ETHER); + if (sc->ifp[phy] == NULL) { + device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); + err = ENOMEM; + break; + } + sc->ifp[phy]->if_softc = sc; sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; Modified: head/sys/dev/etherswitch/rtl8366/rtl8366rb.c ============================================================================== --- head/sys/dev/etherswitch/rtl8366/rtl8366rb.c Wed Jan 24 21:26:01 2018 (r328376) +++ head/sys/dev/etherswitch/rtl8366/rtl8366rb.c Wed Jan 24 21:33:18 2018 (r328377) @@ -239,6 +239,12 @@ rtl8366rb_attach(device_t dev) /* PHYs need an interface, so we generate a dummy one */ for (i = 0; i < sc->numphys; i++) { sc->ifp[i] = if_alloc(IFT_ETHER); + if (sc->ifp[i] == NULL) { + device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); + err = ENOMEM; + break; + } + sc->ifp[i]->if_softc = sc; sc->ifp[i]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; Modified: head/sys/dev/etherswitch/ukswitch/ukswitch.c ============================================================================== --- head/sys/dev/etherswitch/ukswitch/ukswitch.c Wed Jan 24 21:26:01 2018 (r328376) +++ head/sys/dev/etherswitch/ukswitch/ukswitch.c Wed Jan 24 21:33:18 2018 (r328377) @@ -126,6 +126,12 @@ ukswitch_attach_phys(struct ukswitch_softc *sc) sc->ifpport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); + if (sc->ifp[port] == NULL) { + device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); + err = ENOMEM; + break; + } + sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX;