diff options
author | Jiri Slaby <jslaby@suse.cz> | 2011-11-09 15:33:21 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-15 18:52:46 -0500 |
commit | ba5db44895ec3abc5317a9af86001e688a72185c (patch) | |
tree | bb35ca9d8757c581cc9f4cd6871355aaed862244 /drivers/tty/tty_io.c | |
parent | 5b5e70408f1e8a48deebedc26ba982bbc7db343e (diff) |
TTY: coalesce fail paths in tty_open
Move them to the end of the function and use gotos as usual.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r-- | drivers/tty/tty_io.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 00b84984308d..ba9194e7b9c8 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -1916,27 +1916,20 @@ retry_open: | |||
1916 | 1916 | ||
1917 | tty = tty_open_current_tty(device, filp); | 1917 | tty = tty_open_current_tty(device, filp); |
1918 | if (IS_ERR(tty)) { | 1918 | if (IS_ERR(tty)) { |
1919 | tty_unlock(); | 1919 | retval = PTR_ERR(tty); |
1920 | mutex_unlock(&tty_mutex); | 1920 | goto err_unlock; |
1921 | tty_free_file(filp); | ||
1922 | return PTR_ERR(tty); | ||
1923 | } else if (!tty) { | 1921 | } else if (!tty) { |
1924 | driver = tty_lookup_driver(device, filp, &noctty, &index); | 1922 | driver = tty_lookup_driver(device, filp, &noctty, &index); |
1925 | if (IS_ERR(driver)) { | 1923 | if (IS_ERR(driver)) { |
1926 | tty_unlock(); | 1924 | retval = PTR_ERR(driver); |
1927 | mutex_unlock(&tty_mutex); | 1925 | goto err_unlock; |
1928 | tty_free_file(filp); | ||
1929 | return PTR_ERR(driver); | ||
1930 | } | 1926 | } |
1931 | 1927 | ||
1932 | /* check whether we're reopening an existing tty */ | 1928 | /* check whether we're reopening an existing tty */ |
1933 | tty = tty_driver_lookup_tty(driver, inode, index); | 1929 | tty = tty_driver_lookup_tty(driver, inode, index); |
1934 | if (IS_ERR(tty)) { | 1930 | if (IS_ERR(tty)) { |
1935 | tty_unlock(); | 1931 | retval = PTR_ERR(tty); |
1936 | mutex_unlock(&tty_mutex); | 1932 | goto err_unlock; |
1937 | tty_driver_kref_put(driver); | ||
1938 | tty_free_file(filp); | ||
1939 | return PTR_ERR(tty); | ||
1940 | } | 1933 | } |
1941 | } | 1934 | } |
1942 | 1935 | ||
@@ -1952,8 +1945,8 @@ retry_open: | |||
1952 | tty_driver_kref_put(driver); | 1945 | tty_driver_kref_put(driver); |
1953 | if (IS_ERR(tty)) { | 1946 | if (IS_ERR(tty)) { |
1954 | tty_unlock(); | 1947 | tty_unlock(); |
1955 | tty_free_file(filp); | 1948 | retval = PTR_ERR(tty); |
1956 | return PTR_ERR(tty); | 1949 | goto err_file; |
1957 | } | 1950 | } |
1958 | 1951 | ||
1959 | tty_add_file(tty, filp); | 1952 | tty_add_file(tty, filp); |
@@ -2013,6 +2006,15 @@ retry_open: | |||
2013 | tty_unlock(); | 2006 | tty_unlock(); |
2014 | mutex_unlock(&tty_mutex); | 2007 | mutex_unlock(&tty_mutex); |
2015 | return 0; | 2008 | return 0; |
2009 | err_unlock: | ||
2010 | tty_unlock(); | ||
2011 | mutex_unlock(&tty_mutex); | ||
2012 | /* after locks to avoid deadlock */ | ||
2013 | if (!IS_ERR_OR_NULL(driver)) | ||
2014 | tty_driver_kref_put(driver); | ||
2015 | err_file: | ||
2016 | tty_free_file(filp); | ||
2017 | return retval; | ||
2016 | } | 2018 | } |
2017 | 2019 | ||
2018 | 2020 | ||