Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb PR/48964: In urndis(4), initialization of ifnet ...
details: https://anonhg.NetBSD.org/src/rev/4c17557241ac
branches: trunk
changeset: 797089:4c17557241ac
user: skrll <skrll%NetBSD.org@localhost>
date: Sat Jul 05 11:13:12 2014 +0000
description:
PR/48964: In urndis(4), initialization of ifnet structure is not enough,
cause panic.
Update urndis_init to return and error and use as if_init based on the
patch in the PR with stylistic changes from me.
XXX IFF_RUNNING should be ignored here?
diffstat:
sys/dev/usb/if_urndis.c | 42 ++++++++++++++++++++++++------------------
1 files changed, 24 insertions(+), 18 deletions(-)
diffs (116 lines):
diff -r 84203a6cae48 -r 4c17557241ac sys/dev/usb/if_urndis.c
--- a/sys/dev/usb/if_urndis.c Sat Jul 05 10:00:42 2014 +0000
+++ b/sys/dev/usb/if_urndis.c Sat Jul 05 11:13:12 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_urndis.c,v 1.7 2014/07/05 09:30:08 skrll Exp $ */
+/* $NetBSD: if_urndis.c,v 1.8 2014/07/05 11:13:13 skrll Exp $ */
/* $OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
/*
@@ -21,7 +21,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.7 2014/07/05 09:30:08 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.8 2014/07/05 11:13:13 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -76,7 +76,7 @@
static int urndis_rx_list_init(struct urndis_softc *);
static int urndis_tx_list_init(struct urndis_softc *);
-static void urndis_init(struct ifnet *);
+static int urndis_init(struct ifnet *);
static void urndis_stop(struct ifnet *);
static usbd_status urndis_ctrl_msg(struct urndis_softc *, uint8_t, uint8_t,
@@ -1022,53 +1022,57 @@
}
#endif
-static void
+static int
urndis_init(struct ifnet *ifp)
{
struct urndis_softc *sc;
int i, s;
- usbd_status err;
+ int err;
+ usbd_status usberr;
sc = ifp->if_softc;
if (ifp->if_flags & IFF_RUNNING)
- return;
+ return EBUSY;
- if (urndis_ctrl_init(sc) != RNDIS_STATUS_SUCCESS)
- return;
+ err = urndis_ctrl_init(sc);
+ if (err != RNDIS_STATUS_SUCCESS)
+ return EIO;
s = splnet();
- if (urndis_tx_list_init(sc) == ENOBUFS) {
+ err = urndis_tx_list_init(sc);
+ if (err) {
printf("%s: tx list init failed\n",
DEVNAME(sc));
splx(s);
- return;
+ return err;
}
- if (urndis_rx_list_init(sc) == ENOBUFS) {
+ err = urndis_rx_list_init(sc);
+ if (err) {
printf("%s: rx list init failed\n",
DEVNAME(sc));
splx(s);
- return;
+ return err;
}
- err = usbd_open_pipe(sc->sc_iface_data, sc->sc_bulkin_no,
+ usberr = usbd_open_pipe(sc->sc_iface_data, sc->sc_bulkin_no,
USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe);
- if (err) {
+ if (usberr) {
printf("%s: open rx pipe failed: %s\n", DEVNAME(sc),
usbd_errstr(err));
splx(s);
- return;
+ return EIO;
}
- err = usbd_open_pipe(sc->sc_iface_data, sc->sc_bulkout_no,
+ usberr = usbd_open_pipe(sc->sc_iface_data, sc->sc_bulkout_no,
USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe);
- if (err) {
+ if (usberr) {
printf("%s: open tx pipe failed: %s\n", DEVNAME(sc),
usbd_errstr(err));
splx(s);
- return;
+ return EIO;
}
for (i = 0; i < RNDIS_RX_LIST_CNT; i++) {
@@ -1086,6 +1090,7 @@
ifp->if_flags &= ~IFF_OACTIVE;
splx(s);
+ return 0;
}
static void
@@ -1440,6 +1445,7 @@
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_start = urndis_start;
ifp->if_ioctl = urndis_ioctl;
+ ifp->if_init = urndis_init;
#if 0
ifp->if_watchdog = urndis_watchdog;
#endif
Home |
Main Index |
Thread Index |
Old Index