diff options
author | Pekka Enberg <penberg@kernel.org> | 2010-08-24 00:48:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-22 13:19:58 -0400 |
commit | f573bd1764f0f3f47754ca1ae7b2eb2909798a60 (patch) | |
tree | bfc4c03b38bc74bb29dbacce212fe2efc802eb46 /drivers/char/tty_io.c | |
parent | 8a28af7f7e42cd0f107e0d84e4ece89e7ef24d3f (diff) |
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>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r-- | drivers/char/tty_io.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index dc184d4b5638..d6c659f2f659 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -196,12 +196,13 @@ static inline struct tty_struct *file_tty(struct file *file) | |||
196 | } | 196 | } |
197 | 197 | ||
198 | /* Associate a new file with the tty structure */ | 198 | /* Associate a new file with the tty structure */ |
199 | void tty_add_file(struct tty_struct *tty, struct file *file) | 199 | int tty_add_file(struct tty_struct *tty, struct file *file) |
200 | { | 200 | { |
201 | struct tty_file_private *priv; | 201 | struct tty_file_private *priv; |
202 | 202 | ||
203 | /* XXX: must implement proper error handling in callers */ | 203 | priv = kmalloc(sizeof(*priv), GFP_KERNEL); |
204 | priv = kmalloc(sizeof(*priv), GFP_KERNEL|__GFP_NOFAIL); | 204 | if (!priv) |
205 | return -ENOMEM; | ||
205 | 206 | ||
206 | priv->tty = tty; | 207 | priv->tty = tty; |
207 | priv->file = file; | 208 | priv->file = file; |
@@ -210,6 +211,8 @@ void tty_add_file(struct tty_struct *tty, struct file *file) | |||
210 | spin_lock(&tty_files_lock); | 211 | spin_lock(&tty_files_lock); |
211 | list_add(&priv->list, &tty->tty_files); | 212 | list_add(&priv->list, &tty->tty_files); |
212 | spin_unlock(&tty_files_lock); | 213 | spin_unlock(&tty_files_lock); |
214 | |||
215 | return 0; | ||
213 | } | 216 | } |
214 | 217 | ||
215 | /* Delete file from its tty */ | 218 | /* Delete file from its tty */ |
@@ -1877,7 +1880,11 @@ got_driver: | |||
1877 | return PTR_ERR(tty); | 1880 | return PTR_ERR(tty); |
1878 | } | 1881 | } |
1879 | 1882 | ||
1880 | tty_add_file(tty, filp); | 1883 | retval = tty_add_file(tty, filp); |
1884 | if (retval) { | ||
1885 | tty_unlock(); | ||
1886 | return retval; | ||
1887 | } | ||
1881 | 1888 | ||
1882 | check_tty_count(tty, "tty_open"); | 1889 | check_tty_count(tty, "tty_open"); |
1883 | if (tty->driver->type == TTY_DRIVER_TYPE_PTY && | 1890 | if (tty->driver->type == TTY_DRIVER_TYPE_PTY && |