From 2897a1a84d74c44e57465fa4ac34d3a1376e5edb Mon Sep 17 00:00:00 2001 From: mglocker Date: Fri, 5 Feb 2021 08:17:22 +0000 Subject: [PATCH] Prevent that when ugen(4) tries to set an alternative configuration descriptor (usually doesn't happen), that we continue to use an outdated cdesc pointer which still refers to the previous cdesc. Instead update the cdesc pointer to the new configuration descriptor. Reported by Thomas Jeunet ok phessler@ --- sys/dev/usb/ugen.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 78d990b1821..450a39d9055 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ugen.c,v 1.114 2021/02/01 09:21:51 mglocker Exp $ */ +/* $OpenBSD: ugen.c,v 1.115 2021/02/05 08:17:22 mglocker 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 $ */ @@ -220,6 +220,10 @@ ugen_set_config(struct ugen_softc *sc, int configno) err = usbd_set_config_no(dev, configno, 1); if (err) return (err); + cdesc = usbd_get_config_descriptor(dev); + if (cdesc == NULL || + cdesc->bConfigurationValue != configno) + return (USBD_INVAL); } } -- 2.20.1