sched: signedness bug in yield_to()
Subsystems (3)
PATCH 1/1 sched: 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().
include/linux/sched.h +1 -1
@@ -2173,7 +2173,7 @@ static inline void sched_autogroup_fork(struct signal_struct *sig) { }static inline void sched_autogroup_exit (struct signal_struct *sig) { }#endif -extern bool yield_to (struct task_struct *p,bool preempt); +extern int yield_to (struct task_struct *p,bool preempt);extern void set_user_nice (struct task_struct *p,long nice);extern int task_prio (const struct task_struct *p);/**
kernel/sched/core.c +1 -1
@@ -4209,7 +4209,7 @@ EXPORT_SYMBOL(yield);* false (0) if we failed to boost the target. * -ESRCH if there's no task to yield to. */ -bool __sched yield_to(struct task_struct *p, bool preempt) +int __sched yield_to(struct task_struct *p, bool preempt) {struct task_struct *curr = current;struct rq *rq, *p_rq;
include/linux/kvm_host.h +1 -1
@@ -586,7 +586,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn);void kvm_vcpu_block (struct kvm_vcpu *vcpu);void kvm_vcpu_kick (struct kvm_vcpu *vcpu); -bool kvm_vcpu_yield_to (struct kvm_vcpu *target); +int kvm_vcpu_yield_to (struct kvm_vcpu *target);void kvm_vcpu_on_spin (struct kvm_vcpu *vcpu);void kvm_load_guest_fpu (struct kvm_vcpu *vcpu);void kvm_put_guest_fpu (struct kvm_vcpu *vcpu);
virt/kvm/kvm_main.c +2 -2
@@ -1713,11 +1713,11 @@ void kvm_vcpu_kick(struct kvm_vcpu *vcpu)EXPORT_SYMBOL_GPL (kvm_vcpu_kick);#endif /* !CONFIG_S390 */ -bool kvm_vcpu_yield_to (struct kvm_vcpu *target) +int kvm_vcpu_yield_to (struct kvm_vcpu *target) {struct pid *pid;struct task_struct *task =NULL ; -bool ret = false; +int ret =0 ;rcu_read_lock (); pid =rcu_dereference (target->pid);
Peter Zijlstra
maintainerQuoted 7 lines · Dan Carpenter
yield_to()is supposed to return-ESRCHif 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 <[email protected]>
Thanks Dan!
Quoted 7 lines · Dan Carpenter
yield_to()is supposed to return-ESRCHif 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 <[email protected]>
Thanks, Please feel free to add
tip-bot for Dan Carpenter
merge bot[tip:sched/core] sched: Fix signedness bug in yield_to()
In reply to Dan Carpentersched: Fix signedness bug in yield_to()
Commit-ID: fa93384f40deeb294fd29f2fdcadbd0ebc2dedf1 Gitweb: http://git.kernel.org/tip/fa93384f40deeb294fd29f2fdcadbd0ebc2dedf1 Author: Dan Carpenter <[email protected]> AuthorDate: Fri, 23 May 2014 13:20:42 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 5 Jun 2014 11:52:13 +0200
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().
--- include/linux/kvm_host.h | 2 +- include/linux/sched.h | 2 +- kernel/sched/core.c | 2 +- virt/kvm/kvm_main.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)
include/linux/kvm_host.h +1 -1
@@ -584,7 +584,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn);void kvm_vcpu_block (struct kvm_vcpu *vcpu);void kvm_vcpu_kick (struct kvm_vcpu *vcpu); -bool kvm_vcpu_yield_to (struct kvm_vcpu *target); +int kvm_vcpu_yield_to (struct kvm_vcpu *target);void kvm_vcpu_on_spin (struct kvm_vcpu *vcpu);void kvm_load_guest_fpu (struct kvm_vcpu *vcpu);void kvm_put_guest_fpu (struct kvm_vcpu *vcpu);
include/linux/sched.h +1 -1
@@ -2180,7 +2180,7 @@ static inline void sched_autogroup_fork(struct signal_struct *sig) { }static inline void sched_autogroup_exit (struct signal_struct *sig) { }#endif -extern bool yield_to (struct task_struct *p,bool preempt); +extern int yield_to (struct task_struct *p,bool preempt);extern void set_user_nice (struct task_struct *p,long nice);extern int task_prio (const struct task_struct *p);/**
kernel/sched/core.c +1 -1
@@ -4195,7 +4195,7 @@ EXPORT_SYMBOL(yield);* false (0) if we failed to boost the target. * -ESRCH if there's no task to yield to. */ -bool __sched yield_to(struct task_struct *p, bool preempt) +int __sched yield_to(struct task_struct *p, bool preempt) {struct task_struct *curr = current;struct rq *rq, *p_rq;
virt/kvm/kvm_main.c +2 -2
@@ -1708,11 +1708,11 @@ void kvm_vcpu_kick(struct kvm_vcpu *vcpu)EXPORT_SYMBOL_GPL (kvm_vcpu_kick);#endif /* !CONFIG_S390 */ -bool kvm_vcpu_yield_to (struct kvm_vcpu *target) +int kvm_vcpu_yield_to (struct kvm_vcpu *target) {struct pid *pid;struct task_struct *task =NULL ; -bool ret = false; +int ret =0 ;rcu_read_lock (); pid =rcu_dereference (target->pid);