| .. | .. | 
|---|
| 108 | 108 |  | 
|---|
| 109 | 109 | #include <linux/kmod.h> | 
|---|
| 110 | 110 | #include <linux/nsproxy.h> | 
|---|
|  | 111 | +#include "tty.h" | 
|---|
| 111 | 112 |  | 
|---|
| 112 | 113 | #undef TTY_DEBUG_HANGUP | 
|---|
| 113 | 114 | #ifdef TTY_DEBUG_HANGUP | 
|---|
| .. | .. | 
|---|
| 941 | 942 | return i; | 
|---|
| 942 | 943 | } | 
|---|
| 943 | 944 |  | 
|---|
| 944 |  | -static void tty_write_unlock(struct tty_struct *tty) | 
|---|
|  | 945 | +void tty_write_unlock(struct tty_struct *tty) | 
|---|
| 945 | 946 | { | 
|---|
| 946 | 947 | mutex_unlock(&tty->atomic_write_lock); | 
|---|
| 947 | 948 | wake_up_interruptible_poll(&tty->write_wait, EPOLLOUT); | 
|---|
| 948 | 949 | } | 
|---|
| 949 | 950 |  | 
|---|
| 950 |  | -static int tty_write_lock(struct tty_struct *tty, int ndelay) | 
|---|
|  | 951 | +int tty_write_lock(struct tty_struct *tty, int ndelay) | 
|---|
| 951 | 952 | { | 
|---|
| 952 | 953 | if (!mutex_trylock(&tty->atomic_write_lock)) { | 
|---|
| 953 | 954 | if (ndelay) | 
|---|
| .. | .. | 
|---|
| 1237 | 1238 | { | 
|---|
| 1238 | 1239 | struct tty_struct *tty; | 
|---|
| 1239 | 1240 |  | 
|---|
| 1240 |  | -	if (driver->ops->lookup) | 
|---|
|  | 1241 | +	if (driver->ops->lookup) { | 
|---|
| 1241 | 1242 | if (!file) | 
|---|
| 1242 | 1243 | tty = ERR_PTR(-EIO); | 
|---|
| 1243 | 1244 | else | 
|---|
| 1244 | 1245 | tty = driver->ops->lookup(driver, file, idx); | 
|---|
| 1245 |  | -	else | 
|---|
|  | 1246 | +	} else { | 
|---|
|  | 1247 | +		if (idx >= driver->num) | 
|---|
|  | 1248 | +			return ERR_PTR(-EINVAL); | 
|---|
| 1246 | 1249 | tty = driver->ttys[idx]; | 
|---|
| 1247 |  | - | 
|---|
|  | 1250 | +	} | 
|---|
| 1248 | 1251 | if (!IS_ERR(tty)) | 
|---|
| 1249 | 1252 | tty_kref_get(tty); | 
|---|
| 1250 | 1253 | return tty; | 
|---|