summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_hibernate.c
diff options
context:
space:
mode:
authorakfaew <akfaew@openbsd.org>2016-09-01 13:12:59 +0000
committerakfaew <akfaew@openbsd.org>2016-09-01 13:12:59 +0000
commit0d3478fd92dcddb2516ac25faf307324b8e5f1be (patch)
treef6802ff04f4edf1be54c5e217ac466811fc684cb /sys/kern/subr_hibernate.c
parentFix 2 minor issues and a typo in a comment in the pci emulation subsystem. (diff)
downloadwireguard-openbsd-0d3478fd92dcddb2516ac25faf307324b8e5f1be.tar.xz
wireguard-openbsd-0d3478fd92dcddb2516ac25faf307324b8e5f1be.zip
Fix undefined behaviour when comparing pointers by casting them to vaddr_t.
OK mlarkin@
Diffstat (limited to 'sys/kern/subr_hibernate.c')
-rw-r--r--sys/kern/subr_hibernate.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c
index 0ea07637adc..7d360522314 100644
--- a/sys/kern/subr_hibernate.c
+++ b/sys/kern/subr_hibernate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_hibernate.c,v 1.116 2015/05/04 02:18:05 mlarkin Exp $ */
+/* $OpenBSD: subr_hibernate.c,v 1.117 2016/09/01 13:12:59 akfaew Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@@ -156,7 +156,10 @@ hibernate_sort_ranges(union hibernate_info *hib_info)
static __inline int
hibe_cmp(struct hiballoc_entry *l, struct hiballoc_entry *r)
{
- return l < r ? -1 : (l > r);
+ vaddr_t vl = (vaddr_t)l;
+ vaddr_t vr = (vaddr_t)r;
+
+ return vl < vr ? -1 : (vl > vr);
}
RB_PROTOTYPE(hiballoc_addr, hiballoc_entry, hibe_entry, hibe_cmp)