diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2014-05-23 06:20:42 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-06-05 05:52:13 -0400 |
commit | fa93384f40deeb294fd29f2fdcadbd0ebc2dedf1 (patch) | |
tree | 7948bf37a7b399f753937a311488b3f23b01622e | |
parent | 2538d960d0c74cdc639f05723e04a67aed1efdf9 (diff) |
sched: Fix signedness bug in yield_to()
yield_to() is supposed to return -ESRCH if there is no task to
yield to, but because the type is bool that is the same as returning
true.
The only place I see which cares is kvm_vcpu_on_spin().
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Raghavendra <raghavendra.kt@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Link: http://lkml.kernel.org/r/20140523102042.GA7267@mwanda
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | include/linux/kvm_host.h | 2 | ||||
-rw-r--r-- | include/linux/sched.h | 2 | ||||
-rw-r--r-- | kernel/sched/core.c | 2 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 4 |
4 files changed, 5 insertions, 5 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 7d21cf9f4380..3c4bcf146159 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -584,7 +584,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn); | |||
584 | 584 | ||
585 | void kvm_vcpu_block(struct kvm_vcpu *vcpu); | 585 | void kvm_vcpu_block(struct kvm_vcpu *vcpu); |
586 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); | 586 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); |
587 | bool kvm_vcpu_yield_to(struct kvm_vcpu *target); | 587 | int kvm_vcpu_yield_to(struct kvm_vcpu *target); |
588 | void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu); | 588 | void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu); |
589 | void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); | 589 | void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); |
590 | void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); | 590 | void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 0f91d00efd87..6790c3b42072 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2180,7 +2180,7 @@ static inline void sched_autogroup_fork(struct signal_struct *sig) { } | |||
2180 | static inline void sched_autogroup_exit(struct signal_struct *sig) { } | 2180 | static inline void sched_autogroup_exit(struct signal_struct *sig) { } |
2181 | #endif | 2181 | #endif |
2182 | 2182 | ||
2183 | extern bool yield_to(struct task_struct *p, bool preempt); | 2183 | extern int yield_to(struct task_struct *p, bool preempt); |
2184 | extern void set_user_nice(struct task_struct *p, long nice); | 2184 | extern void set_user_nice(struct task_struct *p, long nice); |
2185 | extern int task_prio(const struct task_struct *p); | 2185 | extern int task_prio(const struct task_struct *p); |
2186 | /** | 2186 | /** |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 321d800e4baa..afcc84234a3e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -4195,7 +4195,7 @@ EXPORT_SYMBOL(yield); | |||
4195 | * false (0) if we failed to boost the target. | 4195 | * false (0) if we failed to boost the target. |
4196 | * -ESRCH if there's no task to yield to. | 4196 | * -ESRCH if there's no task to yield to. |
4197 | */ | 4197 | */ |
4198 | bool __sched yield_to(struct task_struct *p, bool preempt) | 4198 | int __sched yield_to(struct task_struct *p, bool preempt) |
4199 | { | 4199 | { |
4200 | struct task_struct *curr = current; | 4200 | struct task_struct *curr = current; |
4201 | struct rq *rq, *p_rq; | 4201 | struct rq *rq, *p_rq; |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 56baae8c2f56..86d1c457458d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -1708,11 +1708,11 @@ void kvm_vcpu_kick(struct kvm_vcpu *vcpu) | |||
1708 | EXPORT_SYMBOL_GPL(kvm_vcpu_kick); | 1708 | EXPORT_SYMBOL_GPL(kvm_vcpu_kick); |
1709 | #endif /* !CONFIG_S390 */ | 1709 | #endif /* !CONFIG_S390 */ |
1710 | 1710 | ||
1711 | bool kvm_vcpu_yield_to(struct kvm_vcpu *target) | 1711 | int kvm_vcpu_yield_to(struct kvm_vcpu *target) |
1712 | { | 1712 | { |
1713 | struct pid *pid; | 1713 | struct pid *pid; |
1714 | struct task_struct *task = NULL; | 1714 | struct task_struct *task = NULL; |
1715 | bool ret = false; | 1715 | int ret = 0; |
1716 | 1716 | ||
1717 | rcu_read_lock(); | 1717 | rcu_read_lock(); |
1718 | pid = rcu_dereference(target->pid); | 1718 | pid = rcu_dereference(target->pid); |