mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-07 13:43:51 +00:00
tty: Remove __GFP_NOFAIL from tty_add_file()
This patch removes __GFP_NOFAIL use from tty_add_file() and adds proper error handling to the call-sites of the function. Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Pekka Enberg <penberg@kernel.org> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
8a28af7f7e
commit
f573bd1764
@ -676,7 +676,9 @@ static int ptmx_open(struct inode *inode, struct file *filp)
|
|||||||
|
|
||||||
set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
|
set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
|
||||||
|
|
||||||
tty_add_file(tty, filp);
|
retval = tty_add_file(tty, filp);
|
||||||
|
if (retval)
|
||||||
|
goto out;
|
||||||
|
|
||||||
retval = devpts_pty_new(inode, tty->link);
|
retval = devpts_pty_new(inode, tty->link);
|
||||||
if (retval)
|
if (retval)
|
||||||
|
@ -196,12 +196,13 @@ static inline struct tty_struct *file_tty(struct file *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Associate a new file with the tty structure */
|
/* Associate a new file with the tty structure */
|
||||||
void tty_add_file(struct tty_struct *tty, struct file *file)
|
int tty_add_file(struct tty_struct *tty, struct file *file)
|
||||||
{
|
{
|
||||||
struct tty_file_private *priv;
|
struct tty_file_private *priv;
|
||||||
|
|
||||||
/* XXX: must implement proper error handling in callers */
|
priv = kmalloc(sizeof(*priv), GFP_KERNEL);
|
||||||
priv = kmalloc(sizeof(*priv), GFP_KERNEL|__GFP_NOFAIL);
|
if (!priv)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
priv->tty = tty;
|
priv->tty = tty;
|
||||||
priv->file = file;
|
priv->file = file;
|
||||||
@ -210,6 +211,8 @@ void tty_add_file(struct tty_struct *tty, struct file *file)
|
|||||||
spin_lock(&tty_files_lock);
|
spin_lock(&tty_files_lock);
|
||||||
list_add(&priv->list, &tty->tty_files);
|
list_add(&priv->list, &tty->tty_files);
|
||||||
spin_unlock(&tty_files_lock);
|
spin_unlock(&tty_files_lock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete file from its tty */
|
/* Delete file from its tty */
|
||||||
@ -1877,7 +1880,11 @@ static int tty_open(struct inode *inode, struct file *filp)
|
|||||||
return PTR_ERR(tty);
|
return PTR_ERR(tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
tty_add_file(tty, filp);
|
retval = tty_add_file(tty, filp);
|
||||||
|
if (retval) {
|
||||||
|
tty_unlock();
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
check_tty_count(tty, "tty_open");
|
check_tty_count(tty, "tty_open");
|
||||||
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
|
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
|
||||||
|
@ -466,7 +466,7 @@ extern void proc_clear_tty(struct task_struct *p);
|
|||||||
extern struct tty_struct *get_current_tty(void);
|
extern struct tty_struct *get_current_tty(void);
|
||||||
extern void tty_default_fops(struct file_operations *fops);
|
extern void tty_default_fops(struct file_operations *fops);
|
||||||
extern struct tty_struct *alloc_tty_struct(void);
|
extern struct tty_struct *alloc_tty_struct(void);
|
||||||
extern void tty_add_file(struct tty_struct *tty, struct file *file);
|
extern int tty_add_file(struct tty_struct *tty, struct file *file);
|
||||||
extern void free_tty_struct(struct tty_struct *tty);
|
extern void free_tty_struct(struct tty_struct *tty);
|
||||||
extern void initialize_tty_struct(struct tty_struct *tty,
|
extern void initialize_tty_struct(struct tty_struct *tty,
|
||||||
struct tty_driver *driver, int idx);
|
struct tty_driver *driver, int idx);
|
||||||
|
Loading…
Reference in New Issue
Block a user