Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci devsw_ok needs to survive across invocations of ...



details:   https://anonhg.NetBSD.org/src/rev/9c80fc548090
branches:  trunk
changeset: 368384:9c80fc548090
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Fri Jul 08 17:32:19 2022 +0000

description:
devsw_ok needs to survive across invocations of nvme_modcmd() so
allocate it statically.

Should address remaining issues with kern/56914

diffstat:

 sys/dev/pci/nvme_pci.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (58 lines):

diff -r e7a9b7a6ea3e -r 9c80fc548090 sys/dev/pci/nvme_pci.c
--- a/sys/dev/pci/nvme_pci.c    Fri Jul 08 16:50:10 2022 +0000
+++ b/sys/dev/pci/nvme_pci.c    Fri Jul 08 17:32:19 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvme_pci.c,v 1.34 2022/07/08 16:10:34 pgoyette Exp $   */
+/*     $NetBSD: nvme_pci.c,v 1.35 2022/07/08 17:32:19 pgoyette Exp $   */
 /*     $OpenBSD: nvme_pci.c,v 1.3 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.34 2022/07/08 16:10:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.35 2022/07/08 17:32:19 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -495,7 +495,7 @@
 #ifdef _MODULE
        devmajor_t cmajor, bmajor;
        extern const struct cdevsw nvme_cdevsw;
-       bool devsw_ok = false;
+       static bool devsw_ok;
 #endif
        int error = 0;
 
@@ -506,6 +506,7 @@
                error = devsw_attach(nvme_cd.cd_name, NULL, &bmajor,
                    &nvme_cdevsw, &cmajor);
                if (error) {
+                       devsw_ok = false;
                        aprint_error("%s: unable to register devsw, err %d\n",
                            nvme_cd.cd_name, error);
                        /* do not abort, just /dev/nvme* will not work */
@@ -516,16 +517,20 @@
                error = config_init_component(cfdriver_ioconf_nvme_pci,
                    cfattach_ioconf_nvme_pci, cfdata_ioconf_nvme_pci);
                if (error) {
-                       if (devsw_ok)
+                       if (devsw_ok) {
                                devsw_detach(NULL, &nvme_cdevsw);
+                               devsw_ok = false;
+                       }
                        break;
                }
                break;
        case MODULE_CMD_FINI:
                error = config_fini_component(cfdriver_ioconf_nvme_pci,
                    cfattach_ioconf_nvme_pci, cfdata_ioconf_nvme_pci);
-               if (devsw_ok)
+               if (devsw_ok) {
                        devsw_detach(NULL, &nvme_cdevsw);
+                       devsw_ok = false;
+               }
                break;
        default:
                break;



Home | Main Index | Thread Index | Old Index