Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb fix free_all_endpoints() to not try calling free...



details:   https://anonhg.NetBSD.org/src/rev/5f8d31831b1c
branches:  trunk
changeset: 980031:5f8d31831b1c
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Wed Jan 20 22:46:33 2021 +0000

description:
fix free_all_endpoints() to not try calling free_pipe() when no endpoints
are allocated; this can happen during config_detach() after attach fails

Reported-by: syzbot+6e8a4c978358ecead03e%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+b25ba25b57561144ac6e%syzkaller.appspotmail.com@localhost

diffstat:

 sys/dev/usb/umidi.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (35 lines):

diff -r a492f5a42d5e -r 5f8d31831b1c sys/dev/usb/umidi.c
--- a/sys/dev/usb/umidi.c       Wed Jan 20 21:59:48 2021 +0000
+++ b/sys/dev/usb/umidi.c       Wed Jan 20 22:46:33 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umidi.c,v 1.82 2020/01/02 08:08:30 maxv Exp $  */
+/*     $NetBSD: umidi.c,v 1.83 2021/01/20 22:46:33 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2001, 2012, 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.82 2020/01/02 08:08:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.83 2021/01/20 22:46:33 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -756,10 +756,14 @@
 {
        int i;
 
+       if (sc->sc_endpoints == NULL) {
+               /* nothing to free */
+               return;
+       }
+
        for (i=0; i<sc->sc_in_num_endpoints+sc->sc_out_num_endpoints; i++)
                free_pipe(&sc->sc_endpoints[i]);
-       if (sc->sc_endpoints != NULL)
-               kmem_free(sc->sc_endpoints, sc->sc_endpoints_len);
+       kmem_free(sc->sc_endpoints, sc->sc_endpoints_len);
        sc->sc_endpoints = sc->sc_out_ep = sc->sc_in_ep = NULL;
 }
 



Home | Main Index | Thread Index | Old Index