Module Name:    src
Committed By:   jmcneill
Date:           Tue Mar  2 11:51:00 UTC 2021

Modified Files:
        src/sys/arch/arm/fdt: arm_simplefb.c
        src/sys/dev/fdt: simplefb.c

Log Message:
Fix previous: Each line is "stride" bytes wide, not "width * depth".

While here, add a comment explaining what this test is doing.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/fdt/arm_simplefb.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/fdt/simplefb.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/fdt/arm_simplefb.c
diff -u src/sys/arch/arm/fdt/arm_simplefb.c:1.9 src/sys/arch/arm/fdt/arm_simplefb.c:1.10
--- src/sys/arch/arm/fdt/arm_simplefb.c:1.9	Tue Mar  2 07:02:05 2021
+++ src/sys/arch/arm/fdt/arm_simplefb.c	Tue Mar  2 11:51:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_simplefb.c,v 1.9 2021/03/02 07:02:05 skrll Exp $ */
+/* $NetBSD: arm_simplefb.c,v 1.10 2021/03/02 11:51:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_vcons.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.9 2021/03/02 07:02:05 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.10 2021/03/02 11:51:00 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -237,8 +237,13 @@ arm_simplefb_preattach(void)
 		return;
 	}
 
-	if (size < width * height * depth)
+	/*
+	 * Make sure that the size of the linear FB mapping is big enough
+	 * to fit the requested screen dimensions.
+	 */
+	if (size < stride * height) {
 		return;
+	}
 
 	if (bus_space_map(bst, addr, size,
 	    BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, &bsh) != 0)

Index: src/sys/dev/fdt/simplefb.c
diff -u src/sys/dev/fdt/simplefb.c:1.13 src/sys/dev/fdt/simplefb.c:1.14
--- src/sys/dev/fdt/simplefb.c:1.13	Tue Mar  2 07:02:06 2021
+++ src/sys/dev/fdt/simplefb.c	Tue Mar  2 11:51:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: simplefb.c,v 1.13 2021/03/02 07:02:06 skrll Exp $ */
+/* $NetBSD: simplefb.c,v 1.14 2021/03/02 11:51:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <[email protected]>
@@ -29,7 +29,7 @@
 #include "opt_wsdisplay_compat.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: simplefb.c,v 1.13 2021/03/02 07:02:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: simplefb.c,v 1.14 2021/03/02 11:51:00 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -169,7 +169,7 @@ simplefb_attach_genfb(struct simplefb_so
 		return ENXIO;
 	}
 
-	if (size < width * height * depth) {
+	if (size < stride * height) {
 		aprint_error(": incorrect size\n");
 		return ENXIO;
 	}

Reply via email to