From 554f81f3187e979f649bc202442c75a4d407ee69 Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 13 Oct 2015 20:57:46 +0000 Subject: [PATCH] Prevent a NULL-pointer dereference when closing a ugen(4) node in case the kernel failed to change the interface of a device. Found the hardway by okan --- sys/dev/usb/ugen.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 9f7eeacc347..e31c11dcb56 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ugen.c,v 1.89 2015/09/15 13:37:44 dcoppa Exp $ */ +/* $OpenBSD: ugen.c,v 1.90 2015/10/13 20:57:46 mpi Exp $ */ /* $NetBSD: ugen.c,v 1.63 2002/11/26 18:49:48 christos Exp $ */ /* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -925,10 +925,8 @@ ugen_set_interface(struct ugen_softc *sc, int ifaceidx, int altno) sce->iface = 0; } - /* change setting */ + /* Try to change setting, if this fails put back the descriptors. */ err = usbd_set_interface(iface, altno); - if (err) - return (err); id = usbd_get_interface_descriptor(iface); for (endptno = 0; endptno < id->bNumEndpoints; endptno++) { -- 2.20.1