mirror of
https://github.com/opnsense/src.git
synced 2026-06-03 13:58:30 -04:00
LinuxKPI: Add ida_alloc_min()
ida_alloc_min() allocates an unused ID. between min and INT_MAX. While here allow end parameter of ida_simple_get() be larger than INT_MAX. Linux caps the value to INT_MAX. Sponsored by: Serenity Cyber Security, LLC Reviewers: manu, bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42806 (cherry picked from commit c7312643b7e5f01adc2a3094c5139f5dcab5f0a4)
This commit is contained in:
parent
67cc189db4
commit
fcfc3fe00d
2 changed files with 9 additions and 3 deletions
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <linux/types.h>
|
||||
|
|
@ -131,6 +132,12 @@ ida_get_new(struct ida *ida, int *p_id)
|
|||
return (ida_get_new_above(ida, 0, p_id));
|
||||
}
|
||||
|
||||
static inline int
|
||||
ida_alloc_min(struct ida *ida, unsigned int min, gfp_t gfp)
|
||||
{
|
||||
return (ida_simple_get(ida, min, UINT_MAX, gfp));
|
||||
}
|
||||
|
||||
static inline int
|
||||
ida_alloc_max(struct ida *ida, unsigned int max, gfp_t gfp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -755,10 +755,9 @@ ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
|
|||
unsigned int max;
|
||||
|
||||
MPASS((int)start >= 0);
|
||||
MPASS((int)end >= 0);
|
||||
|
||||
if (end == 0)
|
||||
max = 0x80000000;
|
||||
if ((int)end <= 0)
|
||||
max = INT_MAX;
|
||||
else {
|
||||
MPASS(end > start);
|
||||
max = end - 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue