Module Name:    src
Committed By:   jmcneill
Date:           Sat Sep 18 09:49:57 UTC 2021

Modified Files:
        src/sys/arch/arm/arm: bus_stubs.c

Log Message:
bus_space_is_equal: fix crash when called with NULL tag


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/arm/bus_stubs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm/bus_stubs.c
diff -u src/sys/arch/arm/arm/bus_stubs.c:1.2 src/sys/arch/arm/arm/bus_stubs.c:1.3
--- src/sys/arch/arm/arm/bus_stubs.c:1.2	Wed Sep  8 11:02:05 2021
+++ src/sys/arch/arm/arm/bus_stubs.c	Sat Sep 18 09:49:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_stubs.c,v 1.2 2021/09/08 11:02:05 jmcneill Exp $	*/
+/*	$NetBSD: bus_stubs.c,v 1.3 2021/09/18 09:49:57 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_stubs.c,v 1.2 2021/09/08 11:02:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_stubs.c,v 1.3 2021/09/18 09:49:57 jmcneill Exp $");
 
 #include <sys/systm.h>
 #include <sys/asan.h>
@@ -40,7 +40,11 @@ __KERNEL_RCSID(0, "$NetBSD: bus_stubs.c,
 bool
 bus_space_is_equal(bus_space_tag_t t1, bus_space_tag_t t2)
 {
-	return t1->bs_cookie == t2->bs_cookie;
+	if (t1 == t2) {
+		return true;
+	}
+
+	return t1 != NULL && t2 != NULL && t1->bs_cookie == t2->bs_cookie;
 }
 
 int

Reply via email to