Module Name:    src
Committed By:   khorben
Date:           Thu Sep 20 09:48:54 UTC 2018

Modified Files:
        src/sys/dev/usb: if_umb.c

Log Message:
Prevent a panic in umb(4) when roaming is disabled

>From OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/if_umb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_umb.c
diff -u src/sys/dev/usb/if_umb.c:1.5 src/sys/dev/usb/if_umb.c:1.6
--- src/sys/dev/usb/if_umb.c:1.5	Thu Sep 20 09:45:16 2018
+++ src/sys/dev/usb/if_umb.c	Thu Sep 20 09:48:54 2018
@@ -1,5 +1,5 @@
-/*	$NetBSD: if_umb.c,v 1.5 2018/09/20 09:45:16 khorben Exp $ */
-/*	$OpenBSD: if_umb.c,v 1.18 2018/02/19 08:59:52 mpi Exp $ */
+/*	$NetBSD: if_umb.c,v 1.6 2018/09/20 09:48:54 khorben Exp $ */
+/*	$OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */
 
 /*
  * Copyright (c) 2016 genua mbH
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.5 2018/09/20 09:45:16 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.6 2018/09/20 09:48:54 khorben Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -944,13 +944,7 @@ umb_statechg_timeout(void *arg)
 {
 	struct umb_softc *sc = arg;
 
-	if (sc->sc_info.regstate == MBIM_REGSTATE_ROAMING && !sc->sc_roaming) {
-		/*
-		 * Query the registration state until we're with the home
-		 * network again.
-		 */
-		umb_cmd(sc, MBIM_CID_REGISTER_STATE, MBIM_CMDOP_QRY, NULL, 0);
-	} else
+	if (sc->sc_info.regstate != MBIM_REGSTATE_ROAMING || sc->sc_roaming)
 		printf("%s: state change timeout\n",DEVNAM(sc));
 	usb_add_task(sc->sc_udev, &sc->sc_umb_task, USB_TASKQ_DRIVER);
 }
@@ -1004,6 +998,15 @@ umb_state_task(void *arg)
 	int	 s;
 	int	 state;
 
+	if (sc->sc_info.regstate == MBIM_REGSTATE_ROAMING && !sc->sc_roaming) {
+		/*
+		 * Query the registration state until we're with the home
+		 * network again.
+		 */
+		umb_cmd(sc, MBIM_CID_REGISTER_STATE, MBIM_CMDOP_QRY, NULL, 0);
+		return;
+	}
+
 	s = splnet();
 	if (ifp->if_flags & IFF_UP)
 		umb_up(sc);

Reply via email to