From: Jiri Slaby Date: Fri, 11 Jan 2013 11:06:27 +0000 (+0100) Subject: pty: return EINVAL for TIOCGPTN for BSD ptys X-Git-Tag: v3.7.4~1 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e5bfd32af29d8ad915c6f1921ca10c8413a7fe28;p=karo-tx-linux.git pty: return EINVAL for TIOCGPTN for BSD ptys commit ded2f295a36d17838fe97e80d7b6ea83381474f8 upstream. Commit bbb63c514a3464342967237a51a21ea8f61ab951 (drivers:tty:fix up ENOIOCTLCMD error handling) changed the default return value from tty ioctl to be ENOTTY and not EINVAL. This is appropriate. But in case of TIOCGPTN for the old BSD ptys glibc started failing because it expects EINVAL to be returned. Only then it continues to obtain the pts name the other way around. So fix this case by explicit return of EINVAL in this case. Signed-off-by: Jiri Slaby Reported-by: Florian Westphal Cc: Alan Cox Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index a82b39939a9c..8cf8d0af1279 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -395,6 +395,8 @@ static int pty_bsd_ioctl(struct tty_struct *tty, return pty_set_lock(tty, (int __user *) arg); case TIOCSIG: /* Send signal to other side of pty */ return pty_signal(tty, (int) arg); + case TIOCGPTN: /* TTY returns ENOTTY, but glibc expects EINVAL here */ + return -EINVAL; } return -ENOIOCTLCMD; }