Permalink
Browse files

Prevent long type overflow of realmem calculation on ILP32 by forcing

calculation to be in quad_t space.  Fix style issue with second parameter
to qmin().

Reported by:	alc
Reviewed by:	bde, alc
  • Loading branch information...
1 parent 5d305ae commit 9a864030fa968b1745a40cb2de03bec9ad84495b andre committed Dec 10, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 sys/kern/subr_param.c
@@ -332,8 +332,8 @@ init_param2(long physpages)
* available kernel memory (physical or kmem).
* At most it can be 3/4 of available kernel memory.
*/
- realmem = qmin(physpages * PAGE_SIZE,
- VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS);
+ realmem = qmin((quad_t)physpages * PAGE_SIZE,
+ VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS);
maxmbufmem = realmem / 2;
TUNABLE_QUAD_FETCH("kern.maxmbufmem", &maxmbufmem);
if (maxmbufmem > (realmem / 4) * 3)

0 comments on commit 9a86403

Please sign in to comment.