Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dan Carpenter and committed by
Ingo Molnar
fa93384f 2538d960

+5 -5
+1 -1
include/linux/kvm_host.h
··· 584 584 585 585 void kvm_vcpu_block(struct kvm_vcpu *vcpu); 586 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 588 void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu); 589 589 void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); 590 590 void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
+1 -1
include/linux/sched.h
··· 2180 2180 static inline void sched_autogroup_exit(struct signal_struct *sig) { } 2181 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 2184 extern void set_user_nice(struct task_struct *p, long nice); 2185 2185 extern int task_prio(const struct task_struct *p); 2186 2186 /**
+1 -1
kernel/sched/core.c
··· 4195 4195 * false (0) if we failed to boost the target. 4196 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 4200 struct task_struct *curr = current; 4201 4201 struct rq *rq, *p_rq;
+2 -2
virt/kvm/kvm_main.c
··· 1708 1708 EXPORT_SYMBOL_GPL(kvm_vcpu_kick); 1709 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 1713 struct pid *pid; 1714 1714 struct task_struct *task = NULL; 1715 - bool ret = false; 1715 + int ret = 0; 1716 1716 1717 1717 rcu_read_lock(); 1718 1718 pid = rcu_dereference(target->pid);