Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c Make sure that we set sc->sc_sme to NULL in fail...



details:   https://anonhg.NetBSD.org/src/rev/392fa03559d0
branches:  trunk
changeset: 978817:392fa03559d0
user:      jdc <jdc%NetBSD.org@localhost>
date:      Sat Dec 05 14:50:33 2020 +0000

description:
Make sure that we set sc->sc_sme to NULL in failure cases in order to avoid
calling sysmon_envsys_unregister() with an invalid struct when we detach.

diffstat:

 sys/dev/i2c/hytp14.c |  3 ++-
 sys/dev/i2c/si70xx.c |  5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diffs (46 lines):

diff -r be1cd6be9d51 -r 392fa03559d0 sys/dev/i2c/hytp14.c
--- a/sys/dev/i2c/hytp14.c      Sat Dec 05 14:48:09 2020 +0000
+++ b/sys/dev/i2c/hytp14.c      Sat Dec 05 14:50:33 2020 +0000
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.9 2019/10/08 21:16:11 kardel Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.10 2020/12/05 14:50:33 jdc Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -189,6 +189,7 @@
                        aprint_error_dev(sc->sc_dev,
                            "unable to attach sensor\n");
                        sysmon_envsys_destroy(sc->sc_sme);
+                       sc->sc_sme = NULL;
                        return;
                }
        }
diff -r be1cd6be9d51 -r 392fa03559d0 sys/dev/i2c/si70xx.c
--- a/sys/dev/i2c/si70xx.c      Sat Dec 05 14:48:09 2020 +0000
+++ b/sys/dev/i2c/si70xx.c      Sat Dec 05 14:50:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: si70xx.c,v 1.5 2019/02/03 12:18:21 mrg Exp $   */
+/*     $NetBSD: si70xx.c,v 1.6 2020/12/05 14:50:33 jdc Exp $   */
 
 /*
  * Copyright (c) 2017 Brad Spencer <brad%anduin.eldar.org@localhost>
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.5 2019/02/03 12:18:21 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.6 2020/12/05 14:50:33 jdc Exp $");
 
 /*
   Driver for the Silicon Labs SI7013/SI7020/SI7021
@@ -718,6 +718,7 @@
                if (error) {
                        aprint_error_dev(self,
                            "Unable to attach sensor %d: %d\n", i, error);
+                       sc->sc_sme = NULL;
                        goto out;
                }
        }



Home | Main Index | Thread Index | Old Index