Module Name:    src
Committed By:   khorben
Date:           Wed Aug  1 12:36:56 UTC 2018

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

Log Message:
Allow kmem_alloc(9) to sleep when attaching

Without this, umb(4) may needlessly fail to attach, like when under memory
pressure.

Thanks skrll@ for the heads-up!


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.2 src/sys/dev/usb/if_umb.c:1.3
--- src/sys/dev/usb/if_umb.c:1.2	Wed Aug  1 12:25:50 2018
+++ src/sys/dev/usb/if_umb.c	Wed Aug  1 12:36:56 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_umb.c,v 1.2 2018/08/01 12:25:50 khorben Exp $ */
+/*	$NetBSD: if_umb.c,v 1.3 2018/08/01 12:36:56 khorben Exp $ */
 /*	$OpenBSD: if_umb.c,v 1.18 2018/02/19 08:59:52 mpi Exp $ */
 
 /*
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.2 2018/08/01 12:25:50 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.3 2018/08/01 12:36:56 khorben Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -498,16 +498,9 @@ umb_attach(device_t parent, device_t sel
 		aprint_error_dev(self, "failed to open control pipe\n");
 		goto fail;
 	}
-	sc->sc_resp_buf = kmem_alloc(sc->sc_ctrl_len, KM_NOSLEEP);
-	if (sc->sc_resp_buf == NULL) {
-		aprint_error_dev(self, "allocation of resp buffer failed\n");
-		goto fail;
-	}
-	sc->sc_ctrl_msg = kmem_alloc(sc->sc_ctrl_len, KM_NOSLEEP);
-	if (sc->sc_ctrl_msg == NULL) {
-		aprint_error_dev(self, "allocation of ctrl msg buffer failed\n");
-		goto fail;
-	}
+
+	sc->sc_resp_buf = kmem_alloc(sc->sc_ctrl_len, KM_SLEEP);
+	sc->sc_ctrl_msg = kmem_alloc(sc->sc_ctrl_len, KM_SLEEP);
 
 	sc->sc_info.regstate = MBIM_REGSTATE_UNKNOWN;
 	sc->sc_info.pin_attempts_left = UMB_VALUE_UNKNOWN;

Reply via email to