Commit 6509f309 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

tty: hide unused pty_get_peer function

TIOCGPTPEER is only used for unix98 PTYs, and we get a warning
when those are disabled:

drivers/tty/pty.c:466:12: error: 'pty_get_peer' defined but not used [-Werror=unused-function]

This moves the respective functions inside of the existing #ifdef.

Fixes: 54ebbfb1 ("tty: add TIOCGPTPEER ioctl")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarAleksa Sarai <asarai@suse.de>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3ee5447e
...@@ -448,48 +448,6 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty, ...@@ -448,48 +448,6 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty,
return retval; return retval;
} }
/**
* pty_open_peer - open the peer of a pty
* @tty: the peer of the pty being opened
*
* Open the cached dentry in tty->link, providing a safe way for userspace
* to get the slave end of a pty (where they have the master fd and cannot
* access or trust the mount namespace /dev/pts was mounted inside).
*/
static struct file *pty_open_peer(struct tty_struct *tty, int flags)
{
if (tty->driver->subtype != PTY_TYPE_MASTER)
return ERR_PTR(-EIO);
return dentry_open(tty->link->driver_data, flags, current_cred());
}
static int pty_get_peer(struct tty_struct *tty, int flags)
{
int fd = -1;
struct file *filp = NULL;
int retval = -EINVAL;
fd = get_unused_fd_flags(0);
if (fd < 0) {
retval = fd;
goto err;
}
filp = pty_open_peer(tty, flags);
if (IS_ERR(filp)) {
retval = PTR_ERR(filp);
goto err_put;
}
fd_install(fd, filp);
return fd;
err_put:
put_unused_fd(fd);
err:
return retval;
}
static void pty_cleanup(struct tty_struct *tty) static void pty_cleanup(struct tty_struct *tty)
{ {
tty_port_put(tty->port); tty_port_put(tty->port);
...@@ -646,9 +604,50 @@ static inline void legacy_pty_init(void) { } ...@@ -646,9 +604,50 @@ static inline void legacy_pty_init(void) { }
/* Unix98 devices */ /* Unix98 devices */
#ifdef CONFIG_UNIX98_PTYS #ifdef CONFIG_UNIX98_PTYS
static struct cdev ptmx_cdev; static struct cdev ptmx_cdev;
/**
* pty_open_peer - open the peer of a pty
* @tty: the peer of the pty being opened
*
* Open the cached dentry in tty->link, providing a safe way for userspace
* to get the slave end of a pty (where they have the master fd and cannot
* access or trust the mount namespace /dev/pts was mounted inside).
*/
static struct file *pty_open_peer(struct tty_struct *tty, int flags)
{
if (tty->driver->subtype != PTY_TYPE_MASTER)
return ERR_PTR(-EIO);
return dentry_open(tty->link->driver_data, flags, current_cred());
}
static int pty_get_peer(struct tty_struct *tty, int flags)
{
int fd = -1;
struct file *filp = NULL;
int retval = -EINVAL;
fd = get_unused_fd_flags(0);
if (fd < 0) {
retval = fd;
goto err;
}
filp = pty_open_peer(tty, flags);
if (IS_ERR(filp)) {
retval = PTR_ERR(filp);
goto err_put;
}
fd_install(fd, filp);
return fd;
err_put:
put_unused_fd(fd);
err:
return retval;
}
static int pty_unix98_ioctl(struct tty_struct *tty, static int pty_unix98_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment