diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ppp/ppp_async.c | 2 | ||||
-rw-r--r-- | drivers/net/ppp/ppp_synctty.c | 2 | ||||
-rw-r--r-- | drivers/tty/tty_ioctl.c | 28 |
3 files changed, 21 insertions, 11 deletions
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c index a031f6b456b4..9c889e0303dd 100644 --- a/drivers/net/ppp/ppp_async.c +++ b/drivers/net/ppp/ppp_async.c | |||
@@ -314,7 +314,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file, | |||
314 | /* flush our buffers and the serial port's buffer */ | 314 | /* flush our buffers and the serial port's buffer */ |
315 | if (arg == TCIOFLUSH || arg == TCOFLUSH) | 315 | if (arg == TCIOFLUSH || arg == TCOFLUSH) |
316 | ppp_async_flush_output(ap); | 316 | ppp_async_flush_output(ap); |
317 | err = tty_perform_flush(tty, arg); | 317 | err = n_tty_ioctl_helper(tty, file, cmd, arg); |
318 | break; | 318 | break; |
319 | 319 | ||
320 | case FIONREAD: | 320 | case FIONREAD: |
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c index 1a12033d2efa..bdf3b13a71a8 100644 --- a/drivers/net/ppp/ppp_synctty.c +++ b/drivers/net/ppp/ppp_synctty.c | |||
@@ -355,7 +355,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file, | |||
355 | /* flush our buffers and the serial port's buffer */ | 355 | /* flush our buffers and the serial port's buffer */ |
356 | if (arg == TCIOFLUSH || arg == TCOFLUSH) | 356 | if (arg == TCIOFLUSH || arg == TCOFLUSH) |
357 | ppp_sync_flush_output(ap); | 357 | ppp_sync_flush_output(ap); |
358 | err = tty_perform_flush(tty, arg); | 358 | err = n_tty_ioctl_helper(tty, file, cmd, arg); |
359 | break; | 359 | break; |
360 | 360 | ||
361 | case FIONREAD: | 361 | case FIONREAD: |
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index 28715e48b2f7..d119034877de 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c | |||
@@ -1122,14 +1122,12 @@ int tty_mode_ioctl(struct tty_struct *tty, struct file *file, | |||
1122 | } | 1122 | } |
1123 | EXPORT_SYMBOL_GPL(tty_mode_ioctl); | 1123 | EXPORT_SYMBOL_GPL(tty_mode_ioctl); |
1124 | 1124 | ||
1125 | int tty_perform_flush(struct tty_struct *tty, unsigned long arg) | 1125 | |
1126 | /* Caller guarantees ldisc reference is held */ | ||
1127 | static int __tty_perform_flush(struct tty_struct *tty, unsigned long arg) | ||
1126 | { | 1128 | { |
1127 | struct tty_ldisc *ld; | 1129 | struct tty_ldisc *ld = tty->ldisc; |
1128 | int retval = tty_check_change(tty); | ||
1129 | if (retval) | ||
1130 | return retval; | ||
1131 | 1130 | ||
1132 | ld = tty_ldisc_ref_wait(tty); | ||
1133 | switch (arg) { | 1131 | switch (arg) { |
1134 | case TCIFLUSH: | 1132 | case TCIFLUSH: |
1135 | if (ld && ld->ops->flush_buffer) { | 1133 | if (ld && ld->ops->flush_buffer) { |
@@ -1147,12 +1145,24 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg) | |||
1147 | tty_driver_flush_buffer(tty); | 1145 | tty_driver_flush_buffer(tty); |
1148 | break; | 1146 | break; |
1149 | default: | 1147 | default: |
1150 | tty_ldisc_deref(ld); | ||
1151 | return -EINVAL; | 1148 | return -EINVAL; |
1152 | } | 1149 | } |
1153 | tty_ldisc_deref(ld); | ||
1154 | return 0; | 1150 | return 0; |
1155 | } | 1151 | } |
1152 | |||
1153 | int tty_perform_flush(struct tty_struct *tty, unsigned long arg) | ||
1154 | { | ||
1155 | struct tty_ldisc *ld; | ||
1156 | int retval = tty_check_change(tty); | ||
1157 | if (retval) | ||
1158 | return retval; | ||
1159 | |||
1160 | ld = tty_ldisc_ref_wait(tty); | ||
1161 | retval = __tty_perform_flush(tty, arg); | ||
1162 | if (ld) | ||
1163 | tty_ldisc_deref(ld); | ||
1164 | return retval; | ||
1165 | } | ||
1156 | EXPORT_SYMBOL_GPL(tty_perform_flush); | 1166 | EXPORT_SYMBOL_GPL(tty_perform_flush); |
1157 | 1167 | ||
1158 | int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, | 1168 | int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, |
@@ -1191,7 +1201,7 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, | |||
1191 | } | 1201 | } |
1192 | return 0; | 1202 | return 0; |
1193 | case TCFLSH: | 1203 | case TCFLSH: |
1194 | return tty_perform_flush(tty, arg); | 1204 | return __tty_perform_flush(tty, arg); |
1195 | default: | 1205 | default: |
1196 | /* Try the mode commands */ | 1206 | /* Try the mode commands */ |
1197 | return tty_mode_ioctl(tty, file, cmd, arg); | 1207 | return tty_mode_ioctl(tty, file, cmd, arg); |