Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev If if_initialize() failed in the attach function, re...



details:   https://anonhg.NetBSD.org/src/rev/ce42fa76bc75
branches:  trunk
changeset: 357010:ce42fa76bc75
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Oct 23 09:27:21 2017 +0000

description:
If if_initialize() failed in the attach function, return.

diffstat:

 sys/dev/ic/bwi.c     |  11 ++++++++---
 sys/dev/pci/if_wm.c  |  11 ++++++++---
 sys/dev/usb/if_upl.c |  12 +++++++++---
 3 files changed, 25 insertions(+), 9 deletions(-)

diffs (104 lines):

diff -r e89ee6612bff -r ce42fa76bc75 sys/dev/ic/bwi.c
--- a/sys/dev/ic/bwi.c  Mon Oct 23 09:25:31 2017 +0000
+++ b/sys/dev/ic/bwi.c  Mon Oct 23 09:27:21 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bwi.c,v 1.32 2017/07/29 01:19:29 riastradh Exp $       */
+/*     $NetBSD: bwi.c,v 1.33 2017/10/23 09:27:21 msaitoh Exp $ */
 /*     $OpenBSD: bwi.c,v 1.74 2008/02/25 21:13:30 mglocker Exp $       */
 
 /*
@@ -48,7 +48,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.32 2017/07/29 01:19:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.33 2017/10/23 09:27:21 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -1021,7 +1021,12 @@
 
        ic->ic_updateslot = bwi_updateslot;
 
-       if_initialize(ifp);
+       error = if_initialize(ifp);
+       if (error != 0) {
+               aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+                   error);
+               goto fail;
+       }
        ieee80211_ifattach(ic);
        ifp->if_percpuq = if_percpuq_create(ifp);
        if_register(ifp);
diff -r e89ee6612bff -r ce42fa76bc75 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Mon Oct 23 09:25:31 2017 +0000
+++ b/sys/dev/pci/if_wm.c       Mon Oct 23 09:27:21 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.540 2017/10/20 09:26:13 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.541 2017/10/23 09:27:21 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.540 2017/10/20 09:26:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.541 2017/10/23 09:27:21 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2753,7 +2753,12 @@
 #endif
 
        /* Attach the interface. */
-       if_initialize(ifp);
+       error = if_initialize(ifp);
+       if (error != 0) {
+               aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+                   error);
+               return; /* Error */
+       }
        sc->sc_ipq = if_percpuq_create(&sc->sc_ethercom.ec_if);
        ether_ifattach(ifp, enaddr);
        if_register(ifp);
diff -r e89ee6612bff -r ce42fa76bc75 sys/dev/usb/if_upl.c
--- a/sys/dev/usb/if_upl.c      Mon Oct 23 09:25:31 2017 +0000
+++ b/sys/dev/usb/if_upl.c      Mon Oct 23 09:27:21 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_upl.c,v 1.59 2017/01/12 18:26:08 maya Exp $ */
+/*     $NetBSD: if_upl.c,v 1.60 2017/10/23 09:27:21 msaitoh Exp $      */
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.59 2017/01/12 18:26:08 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.60 2017/10/23 09:27:21 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -228,6 +228,7 @@
        usb_interface_descriptor_t      *id;
        usb_endpoint_descriptor_t       *ed;
        int                     i;
+       int                     rv;
 
        DPRINTFN(5,(" : upl_attach: sc=%p, dev=%p", sc, dev));
 
@@ -307,7 +308,12 @@
        IFQ_SET_READY(&ifp->if_snd);
 
        /* Attach the interface. */
-       if_initialize(ifp);
+       rv = if_initialize(ifp);
+       if (rv != 0) {
+               aprint_error_dev(self, "if_initialize failed(%d)\n", rv);
+               splx(s);
+               return;
+       }
        if_register(ifp);
        if_alloc_sadl(ifp);
 



Home | Main Index | Thread Index | Old Index