tty: tty_jobctrl: use guard() in tiocgsid()
PATCH 1/1 tty: tty_jobctrl: use guard() in tiocgsid()
guard()s express more clearly what the lock protects and let the function return immediately instead of jumping to an unlock label.
Signed-off-by John de la Garza <[email protected]>
--- drivers/tty/tty_jobctrl.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/tty/tty_jobctrl.c +5 -10
@@ -542,7 +542,6 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t*/ static int tiocgsid (struct tty_struct *tty,struct tty_struct *real_tty,pid_t __user *p) { -unsigned long flags;pid_t sid;/*
@@ -552,17 +551,13 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _if (tty == real_tty && current->signal->tty != real_tty)return -ENOTTY ; -spin_lock_irqsave (&real_tty->ctrl.lock, flags); -if (!real_tty->ctrl.session) - goto err; - sid =pid_vnr (real_tty->ctrl.session); -spin_unlock_irqrestore (&real_tty->ctrl.lock, flags); + scoped_guard(spinlock_irqsave, &real_tty->ctrl.lock) { +if (!real_tty->ctrl.session) +return -ENOTTY ; + sid =pid_vnr (real_tty->ctrl.session); + }return put_user (sid, p); - -err: -spin_unlock_irqrestore (&real_tty->ctrl.lock, flags); -return -ENOTTY ; }/*
Signature · 1 line
2.54.0
Quoted 2 lines · John de la Garza
guard()s express more clearly what the lock protects and let the function return immediately instead of jumping to an unlock label.
Why did you send this twice? Other than that:
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