tty: tty_jobctrl: use guard()s in tiocspgrp()
PATCH 1/1 tty: tty_jobctrl: use guard()s in tiocspgrp()
Convert the manual spin_lock_irq()/rcu_read_lock() nesting in tiocspgrp() to scoped guard()s. This drops the out_unlock and out_unlock_ctrl labels and lets the error paths return directly.
No functional change intended.
Signed-off-by John de la Garza <[email protected]>
--- drivers/tty/tty_jobctrl.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
drivers/tty/tty_jobctrl.c +10 -16
@@ -506,29 +506,23 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_tif (pgrp_nr <0 )return -EINVAL ; -spin_lock_irq (&real_tty->ctrl.lock); +guard (spinlock_irq)(&real_tty->ctrl.lock);if (!current->signal->tty || (current->signal->tty != real_tty) || - (real_tty->ctrl.session !=task_session (current))) { - retval = -ENOTTY ; - goto out_unlock_ctrl; - } -rcu_read_lock (); + (real_tty->ctrl.session !=task_session (current))) +return -ENOTTY ; + +guard (rcu)(); pgrp =find_vpid (pgrp_nr); - retval = -ESRCH ;if (!pgrp) - goto out_unlock; - retval = -EPERM ; +return -ESRCH ;if (session_of_pgrp (pgrp) !=task_session (current)) - goto out_unlock; - retval =0 ; +return -EPERM ; +put_pid (real_tty->ctrl.pgrp); real_tty->ctrl.pgrp =get_pid (pgrp); -out_unlock: -rcu_read_unlock (); -out_unlock_ctrl: -spin_unlock_irq (&real_tty->ctrl.lock); -return retval; + +return 0 ; }/**
Signature · 1 line
2.53.0
Quoted 5 lines · John de la Garza
Convert the manual spin_lock_irq()/rcu_read_lock() nesting in
tiocspgrp()to scoped guard()s. This drops theout_unlockandout_unlock_ctrllabels and lets the error paths return directly.No functional change intended.
Nice cleanup!
Reviewed-by Jiri Slaby <[email protected]>
Quoted 1 line
Signed-off-by John de la Garza <[email protected]>
thanks,
Signature · 2 lines
js suse labs