projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[firefly-linux-kernel-4.4.55.git]
/
kernel
/
posix-timers.c
diff --git
a/kernel/posix-timers.c
b/kernel/posix-timers.c
index 10349d5f2ec311afe81c17ff533aec6ddbd83d09..6edbb2c55c22fd56a61eb6665e32087592a81fc3 100644
(file)
--- a/
kernel/posix-timers.c
+++ b/
kernel/posix-timers.c
@@
-552,24
+552,22
@@
SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
return -EAGAIN;
spin_lock_init(&new_timer->it_lock);
return -EAGAIN;
spin_lock_init(&new_timer->it_lock);
- retry:
- if (unlikely(!idr_pre_get(&posix_timers_id, GFP_KERNEL))) {
- error = -EAGAIN;
- goto out;
- }
+
+ idr_preload(GFP_KERNEL);
spin_lock_irq(&idr_lock);
spin_lock_irq(&idr_lock);
- error = idr_
get_new(&posix_timers_id, new_timer, &new_timer_id
);
+ error = idr_
alloc(&posix_timers_id, new_timer, 0, 0, GFP_NOWAIT
);
spin_unlock_irq(&idr_lock);
spin_unlock_irq(&idr_lock);
- if (error) {
- if (error == -EAGAIN)
- goto retry;
+ idr_preload_end();
+ if (error < 0) {
/*
* Weird looking, but we return EAGAIN if the IDR is
* full (proper POSIX return value for this)
*/
/*
* Weird looking, but we return EAGAIN if the IDR is
* full (proper POSIX return value for this)
*/
- error = -EAGAIN;
+ if (error == -ENOSPC)
+ error = -EAGAIN;
goto out;
}
goto out;
}
+ new_timer_id = error;
it_id_set = IT_ID_SET;
new_timer->it_id = (timer_t) new_timer_id;
it_id_set = IT_ID_SET;
new_timer->it_id = (timer_t) new_timer_id;
@@
-639,6
+637,13
@@
static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags)
{
struct k_itimer *timr;
{
struct k_itimer *timr;
+ /*
+ * timer_t could be any type >= int and we want to make sure any
+ * @timer_id outside positive int range fails lookup.
+ */
+ if ((unsigned long long)timer_id > INT_MAX)
+ return NULL;
+
rcu_read_lock();
timr = idr_find(&posix_timers_id, (int)timer_id);
if (timr) {
rcu_read_lock();
timr = idr_find(&posix_timers_id, (int)timer_id);
if (timr) {