Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/sdmmc Don't crash on detach where interlock == NULL.



details:   https://anonhg.NetBSD.org/src/rev/b413ef1c6503
branches:  trunk
changeset: 1021685:b413ef1c6503
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Jun 13 09:58:28 2021 +0000

description:
Don't crash on detach where interlock == NULL.

diffstat:

 sys/dev/sdmmc/sdmmc.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 1b56980ddd13 -r b413ef1c6503 sys/dev/sdmmc/sdmmc.c
--- a/sys/dev/sdmmc/sdmmc.c     Sun Jun 13 09:50:02 2021 +0000
+++ b/sys/dev/sdmmc/sdmmc.c     Sun Jun 13 09:58:28 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdmmc.c,v 1.41 2021/04/24 23:36:59 thorpej Exp $       */
+/*     $NetBSD: sdmmc.c,v 1.42 2021/06/13 09:58:28 mlelstv Exp $       */
 /*     $OpenBSD: sdmmc.c,v 1.18 2009/01/09 10:58:38 jsg Exp $  */
 
 /*
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.41 2021/04/24 23:36:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.42 2021/06/13 09:58:28 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -300,14 +300,16 @@
        } else {
                KASSERT(task->sc == NULL);
                KASSERT(!task->onqueue);
-               mutex_exit(interlock);
+               if (interlock != NULL)
+                       mutex_exit(interlock);
                while (sc->sc_curtask == task) {
                        KASSERT(curlwp != sc->sc_tskq_lwp);
                        cv_wait(&sc->sc_tskq_cv, &sc->sc_tskq_mtx);
                }
-               if (!mutex_tryenter(interlock)) {
+               if (interlock == NULL || !mutex_tryenter(interlock)) {
                        mutex_exit(&sc->sc_tskq_mtx);
-                       mutex_enter(interlock);
+                       if (interlock != NULL)
+                               mutex_enter(interlock);
                        mutex_enter(&sc->sc_tskq_mtx);
                }
                cancelled = false;



Home | Main Index | Thread Index | Old Index