Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 Add a NULL check on the structure pointer, ...



details:   https://anonhg.NetBSD.org/src/rev/78154806a488
branches:  trunk
changeset: 461100:78154806a488
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Nov 16 10:19:29 2019 +0000

description:
Add a NULL check on the structure pointer, not to retrieve its first field
if it is NULL. The previous code was not buggy strictly speaking. This
change probably doesn't change anything, except removing assumptions in the
compiler optimization passes, which too probably doesn't change anything in
this case.

Reported-by: syzbot+110b29c1973f38a38026%syzkaller.appspotmail.com@localhost

diffstat:

 sys/arch/x86/x86/pmap.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 055720ceebb5 -r 78154806a488 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Sat Nov 16 10:15:10 2019 +0000
+++ b/sys/arch/x86/x86/pmap.c   Sat Nov 16 10:19:29 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.340 2019/11/14 17:09:23 maxv Exp $  */
+/*     $NetBSD: pmap.c,v 1.341 2019/11/16 10:19:29 maxv Exp $  */
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.340 2019/11/14 17:09:23 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.341 2019/11/16 10:19:29 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -541,6 +541,8 @@
 pve_to_pvpte(struct pv_entry *pve)
 {
 
+       if (pve == NULL)
+               return NULL;
        KASSERT((void *)&pve->pve_pte == (void *)pve);
        return &pve->pve_pte;
 }



Home | Main Index | Thread Index | Old Index