Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Use unsigned to avoid undefined behavior in agpa...



details:   https://anonhg.NetBSD.org/src/rev/90f896d38a32
branches:  trunk
changeset: 455350:90f896d38a32
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Oct 15 16:59:15 2019 +0000

description:
Use unsigned to avoid undefined behavior in agpattach(). Found by kUBSan.

diffstat:

 sys/dev/pci/agp.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 90036f4767f3 -r 90f896d38a32 sys/dev/pci/agp.c
--- a/sys/dev/pci/agp.c Tue Oct 15 16:30:49 2019 +0000
+++ b/sys/dev/pci/agp.c Tue Oct 15 16:59:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: agp.c,v 1.85 2018/08/27 07:34:54 riastradh Exp $       */
+/*     $NetBSD: agp.c,v 1.86 2019/10/15 16:59:15 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2000 Doug Rabson
@@ -65,7 +65,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: agp.c,v 1.85 2018/08/27 07:34:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: agp.c,v 1.86 2019/10/15 16:59:15 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -312,7 +312,7 @@
        return (1);
 }
 
-static const int agp_max[][2] = {
+static const u_int agp_max[][2] = {
        {0,     0},
        {32,    4},
        {64,    28},
@@ -332,7 +332,8 @@
        struct pci_attach_args *pa = &apa->apa_pci_args;
        struct agp_softc *sc = device_private(self);
        const struct agp_product *ap;
-       int memsize, i, ret;
+       int ret;
+       u_int memsize, i;
 
        ap = agp_lookup(pa);
        KASSERT(ap != NULL);



Home | Main Index | Thread Index | Old Index