aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric van Gyzen <vangyzen@FreeBSD.org>2020-09-18 16:48:08 +0000
committerEric van Gyzen <vangyzen@FreeBSD.org>2020-09-18 16:48:08 +0000
commitf9cc8410e16ab0870c218b7a9541464ef10a8d34 (patch)
tree70cab1a48a5c749a8b8d98b017db20d8f4dd42a7
parent6dadc5d1cdec44cad788c3cc5135ddb858885212 (diff)
downloadsrc-f9cc8410e16ab0870c218b7a9541464ef10a8d34.tar.gz
src-f9cc8410e16ab0870c218b7a9541464ef10a8d34.zip
vm_ooffset_t is now unsigned
vm_ooffset_t is now unsigned. Remove some tests for negative values, or make other adjustments accordingly. Reported by: Coverity Reviewed by: kib markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D26214
Notes
Notes: svn path=/head/; revision=365886
-rw-r--r--sys/dev/fb/fbd.c2
-rw-r--r--sys/dev/ksyms/ksyms.c2
-rw-r--r--sys/dev/vt/hw/fb/vt_fb.c2
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c12
-rw-r--r--sys/kern/uipc_shm.c2
-rw-r--r--sys/kern/vfs_vnops.c2
-rw-r--r--sys/vm/vnode_pager.c3
7 files changed, 12 insertions, 13 deletions
diff --git a/sys/dev/fb/fbd.c b/sys/dev/fb/fbd.c
index 4d0dcf001911..36439af9256c 100644
--- a/sys/dev/fb/fbd.c
+++ b/sys/dev/fb/fbd.c
@@ -176,7 +176,7 @@ fb_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot,
if (info->fb_flags & FB_FLAG_NOMMAP)
return (ENODEV);
- if (offset >= 0 && offset < info->fb_size) {
+ if (offset < info->fb_size) {
if (info->fb_pbase == 0)
*paddr = vtophys((uint8_t *)info->fb_vbase + offset);
else
diff --git a/sys/dev/ksyms/ksyms.c b/sys/dev/ksyms/ksyms.c
index 6e7b032ea340..2fb3d9bd2f79 100644
--- a/sys/dev/ksyms/ksyms.c
+++ b/sys/dev/ksyms/ksyms.c
@@ -484,7 +484,7 @@ ksyms_mmap_single(struct cdev *dev, vm_ooffset_t *offset, vm_size_t size,
if (error != 0)
return (error);
- if (*offset < 0 || *offset >= round_page(sc->sc_objsz) ||
+ if (*offset >= round_page(sc->sc_objsz) ||
size > round_page(sc->sc_objsz) - *offset ||
(nprot & ~PROT_READ) != 0)
return (EINVAL);
diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c
index 58111ada3668..01850f789d29 100644
--- a/sys/dev/vt/hw/fb/vt_fb.c
+++ b/sys/dev/vt/hw/fb/vt_fb.c
@@ -140,7 +140,7 @@ vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, vm_paddr_t *paddr,
if (info->fb_flags & FB_FLAG_NOMMAP)
return (ENODEV);
- if (offset >= 0 && offset < info->fb_size) {
+ if (offset < info->fb_size) {
if (info->fb_pbase == 0) {
*paddr = vtophys((uint8_t *)info->fb_vbase + offset);
} else {
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 0068656968b5..e454f45a089f 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -178,12 +178,14 @@ RB_PROTOTYPE_STATIC(tmpfs_dir, tmpfs_dirent, uh.td_entries, tmpfs_dirtree_cmp);
size_t
tmpfs_mem_avail(void)
{
- vm_ooffset_t avail;
+ size_t avail;
+ long reserved;
- avail = swap_pager_avail + vm_free_count() - tmpfs_pages_reserved;
- if (__predict_false(avail < 0))
- avail = 0;
- return (avail);
+ avail = swap_pager_avail + vm_free_count();
+ reserved = atomic_load_long(&tmpfs_pages_reserved);
+ if (__predict_false(avail < reserved))
+ return (0);
+ return (avail - reserved);
}
size_t
diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c
index 465c885cebad..c0fdccefda49 100644
--- a/sys/kern/uipc_shm.c
+++ b/sys/kern/uipc_shm.c
@@ -1577,7 +1577,7 @@ shm_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t objsize,
#ifdef _LP64
objsize > OFF_MAX ||
#endif
- foff < 0 || foff > OFF_MAX - objsize) {
+ foff > OFF_MAX - objsize) {
error = EINVAL;
goto out;
}
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 671ee089d445..cae3c0653361 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -2630,7 +2630,7 @@ vn_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size,
#ifdef _LP64
size > OFF_MAX ||
#endif
- foff < 0 || foff > OFF_MAX - size)
+ foff > OFF_MAX - size)
return (EINVAL);
writecounted = FALSE;
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index 19ba1f525dfe..0c67a3785ea2 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -541,9 +541,6 @@ vnode_pager_addr(struct vnode *vp, vm_ooffset_t address, daddr_t *rtaddress,
daddr_t vblock;
daddr_t voffset;
- if (address < 0)
- return -1;
-
if (VN_IS_DOOMED(vp))
return -1;