Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm mmap(2): Assert size != 0 in non-anonymous case.



details:   https://anonhg.NetBSD.org/src/rev/5ea4aa9120d7
branches:  trunk
changeset: 368338:5ea4aa9120d7
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 06 00:40:28 2022 +0000

description:
mmap(2): Assert size != 0 in non-anonymous case.

This is guaranteed by a test earlier; adding the assertion just makes
it clearer that it applies to the branch where we call fo_mmap -- no
functional change intended.

diffstat:

 sys/uvm/uvm_mmap.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 2e1f72409ad0 -r 5ea4aa9120d7 sys/uvm/uvm_mmap.c
--- a/sys/uvm/uvm_mmap.c        Wed Jul 06 00:40:16 2022 +0000
+++ b/sys/uvm/uvm_mmap.c        Wed Jul 06 00:40:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_mmap.c,v 1.181 2022/07/06 00:40:16 riastradh Exp $ */
+/*     $NetBSD: uvm_mmap.c,v 1.182 2022/07/06 00:40:28 riastradh Exp $ */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.181 2022/07/06 00:40:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.182 2022/07/06 00:40:28 riastradh Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_pax.h"
@@ -368,6 +368,8 @@
 
        advice = UVM_ADV_NORMAL;
        if ((flags & MAP_ANON) == 0) {
+               KASSERT(size != 0);
+
                if ((fp = fd_getfile(fd)) == NULL)
                        return EBADF;
 



Home | Main Index | Thread Index | Old Index