diff --git a/debian/binary-custom.d/openvz/patchset/0001-2.6.24-ovz002.patch b/debian/binary-custom.d/openvz/patchset/0001-2.6.24-ovz002.patch
index 729b278..6a8a613 100644
--- a/debian/binary-custom.d/openvz/patchset/0001-2.6.24-ovz002.patch
+++ b/debian/binary-custom.d/openvz/patchset/0001-2.6.24-ovz002.patch
@@ -62556,7 +62556,7 @@ Index: kernel/kernel/pid.c
 +	return pid;
 +}
 +
- static int next_pidmap(struct pid_namespace *pid_ns, int last)
+ static int next_pidmap(struct pid_namespace *pid_ns, unsigned int last)
  {
  	int offset;
 @@ -198,6 +231,7 @@
diff --git a/kernel/pid.c b/kernel/pid.c
index f815455..29f0ac0 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -181,11 +181,14 @@ static int alloc_pidmap(struct pid_namespace *pid_ns)
 	return -1;
 }
 
-static int next_pidmap(struct pid_namespace *pid_ns, int last)
+static int next_pidmap(struct pid_namespace *pid_ns, unsigned int last)
 {
 	int offset;
 	struct pidmap *map, *end;
 
+	if (last >= PID_MAX_LIMIT)
+		return -1;
+
 	offset = (last + 1) & BITS_PER_PAGE_MASK;
 	map = &pid_ns->pidmap[(last + 1)/BITS_PER_PAGE];
 	end = &pid_ns->pidmap[PIDMAP_ENTRIES];
