diff options
author | Alan Cox <alan@redhat.com> | 2008-10-13 05:44:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-13 12:51:44 -0400 |
commit | 51383f69ec56fe3f425d5255fb43e18c445e061c (patch) | |
tree | f9d9e280892702c3a47ffa807c0937ea9c80e315 /drivers | |
parent | ea1afd256258f04a290aaa7fd5c2d4deb2e79e26 (diff) |
tty: Remove lots of NULL checks
Many tty drivers contain 'can't happen' checks against NULL pointers passed
in by the tty layer. These have never been possible to occur. Even more
importantly if they ever do occur we want to know as it would be a serious
bug.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/amiserial.c | 6 | ||||
-rw-r--r-- | drivers/char/generic_serial.c | 21 | ||||
-rw-r--r-- | drivers/char/istallion.c | 6 | ||||
-rw-r--r-- | drivers/char/mxser.c | 5 | ||||
-rw-r--r-- | drivers/char/n_r3964.c | 8 | ||||
-rw-r--r-- | drivers/char/stallion.c | 34 |
6 files changed, 1 insertions, 79 deletions
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index 6e763e3f5a81..98821f97583c 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c | |||
@@ -837,9 +837,6 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch) | |||
837 | struct async_struct *info; | 837 | struct async_struct *info; |
838 | unsigned long flags; | 838 | unsigned long flags; |
839 | 839 | ||
840 | if (!tty) | ||
841 | return 0; | ||
842 | |||
843 | info = tty->driver_data; | 840 | info = tty->driver_data; |
844 | 841 | ||
845 | if (serial_paranoia_check(info, tty->name, "rs_put_char")) | 842 | if (serial_paranoia_check(info, tty->name, "rs_put_char")) |
@@ -892,9 +889,6 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count | |||
892 | struct async_struct *info; | 889 | struct async_struct *info; |
893 | unsigned long flags; | 890 | unsigned long flags; |
894 | 891 | ||
895 | if (!tty) | ||
896 | return 0; | ||
897 | |||
898 | info = tty->driver_data; | 892 | info = tty->driver_data; |
899 | 893 | ||
900 | if (serial_paranoia_check(info, tty->name, "rs_write")) | 894 | if (serial_paranoia_check(info, tty->name, "rs_write")) |
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c index 19d3afb0e50c..c6090f84a2e4 100644 --- a/drivers/char/generic_serial.c +++ b/drivers/char/generic_serial.c | |||
@@ -54,8 +54,6 @@ int gs_put_char(struct tty_struct * tty, unsigned char ch) | |||
54 | 54 | ||
55 | func_enter (); | 55 | func_enter (); |
56 | 56 | ||
57 | if (!tty) return 0; | ||
58 | |||
59 | port = tty->driver_data; | 57 | port = tty->driver_data; |
60 | 58 | ||
61 | if (!port) return 0; | 59 | if (!port) return 0; |
@@ -97,8 +95,6 @@ int gs_write(struct tty_struct * tty, | |||
97 | 95 | ||
98 | func_enter (); | 96 | func_enter (); |
99 | 97 | ||
100 | if (!tty) return 0; | ||
101 | |||
102 | port = tty->driver_data; | 98 | port = tty->driver_data; |
103 | 99 | ||
104 | if (!port) return 0; | 100 | if (!port) return 0; |
@@ -185,7 +181,6 @@ static int gs_real_chars_in_buffer(struct tty_struct *tty) | |||
185 | struct gs_port *port; | 181 | struct gs_port *port; |
186 | func_enter (); | 182 | func_enter (); |
187 | 183 | ||
188 | if (!tty) return 0; | ||
189 | port = tty->driver_data; | 184 | port = tty->driver_data; |
190 | 185 | ||
191 | if (!port->rd) return 0; | 186 | if (!port->rd) return 0; |
@@ -274,8 +269,6 @@ void gs_flush_buffer(struct tty_struct *tty) | |||
274 | 269 | ||
275 | func_enter (); | 270 | func_enter (); |
276 | 271 | ||
277 | if (!tty) return; | ||
278 | |||
279 | port = tty->driver_data; | 272 | port = tty->driver_data; |
280 | 273 | ||
281 | if (!port) return; | 274 | if (!port) return; |
@@ -296,8 +289,6 @@ void gs_flush_chars(struct tty_struct * tty) | |||
296 | 289 | ||
297 | func_enter (); | 290 | func_enter (); |
298 | 291 | ||
299 | if (!tty) return; | ||
300 | |||
301 | port = tty->driver_data; | 292 | port = tty->driver_data; |
302 | 293 | ||
303 | if (!port) return; | 294 | if (!port) return; |
@@ -321,8 +312,6 @@ void gs_stop(struct tty_struct * tty) | |||
321 | 312 | ||
322 | func_enter (); | 313 | func_enter (); |
323 | 314 | ||
324 | if (!tty) return; | ||
325 | |||
326 | port = tty->driver_data; | 315 | port = tty->driver_data; |
327 | 316 | ||
328 | if (!port) return; | 317 | if (!port) return; |
@@ -341,8 +330,6 @@ void gs_start(struct tty_struct * tty) | |||
341 | { | 330 | { |
342 | struct gs_port *port; | 331 | struct gs_port *port; |
343 | 332 | ||
344 | if (!tty) return; | ||
345 | |||
346 | port = tty->driver_data; | 333 | port = tty->driver_data; |
347 | 334 | ||
348 | if (!port) return; | 335 | if (!port) return; |
@@ -393,8 +380,6 @@ void gs_hangup(struct tty_struct *tty) | |||
393 | 380 | ||
394 | func_enter (); | 381 | func_enter (); |
395 | 382 | ||
396 | if (!tty) return; | ||
397 | |||
398 | port = tty->driver_data; | 383 | port = tty->driver_data; |
399 | tty = port->port.tty; | 384 | tty = port->port.tty; |
400 | if (!tty) | 385 | if (!tty) |
@@ -426,8 +411,6 @@ int gs_block_til_ready(void *port_, struct file * filp) | |||
426 | 411 | ||
427 | tty = port->port.tty; | 412 | tty = port->port.tty; |
428 | 413 | ||
429 | if (!tty) return 0; | ||
430 | |||
431 | gs_dprintk (GS_DEBUG_BTR, "Entering gs_block_till_ready.\n"); | 414 | gs_dprintk (GS_DEBUG_BTR, "Entering gs_block_till_ready.\n"); |
432 | /* | 415 | /* |
433 | * If the device is in the middle of being closed, then block | 416 | * If the device is in the middle of being closed, then block |
@@ -523,8 +506,6 @@ void gs_close(struct tty_struct * tty, struct file * filp) | |||
523 | 506 | ||
524 | func_enter (); | 507 | func_enter (); |
525 | 508 | ||
526 | if (!tty) return; | ||
527 | |||
528 | port = (struct gs_port *) tty->driver_data; | 509 | port = (struct gs_port *) tty->driver_data; |
529 | 510 | ||
530 | if (!port) return; | 511 | if (!port) return; |
@@ -621,8 +602,6 @@ void gs_set_termios (struct tty_struct * tty, | |||
621 | 602 | ||
622 | func_enter(); | 603 | func_enter(); |
623 | 604 | ||
624 | if (!tty) return; | ||
625 | |||
626 | port = tty->driver_data; | 605 | port = tty->driver_data; |
627 | 606 | ||
628 | if (!port) return; | 607 | if (!port) return; |
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 96ee1121acef..505d7a1f6b8c 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -1375,8 +1375,6 @@ static void stli_flushchars(struct tty_struct *tty) | |||
1375 | stli_txcookrealsize = 0; | 1375 | stli_txcookrealsize = 0; |
1376 | stli_txcooktty = NULL; | 1376 | stli_txcooktty = NULL; |
1377 | 1377 | ||
1378 | if (tty == NULL) | ||
1379 | return; | ||
1380 | if (cooktty == NULL) | 1378 | if (cooktty == NULL) |
1381 | return; | 1379 | return; |
1382 | if (tty != cooktty) | 1380 | if (tty != cooktty) |
@@ -1732,8 +1730,6 @@ static void stli_settermios(struct tty_struct *tty, struct ktermios *old) | |||
1732 | struct ktermios *tiosp; | 1730 | struct ktermios *tiosp; |
1733 | asyport_t aport; | 1731 | asyport_t aport; |
1734 | 1732 | ||
1735 | if (tty == NULL) | ||
1736 | return; | ||
1737 | portp = tty->driver_data; | 1733 | portp = tty->driver_data; |
1738 | if (portp == NULL) | 1734 | if (portp == NULL) |
1739 | return; | 1735 | return; |
@@ -1938,8 +1934,6 @@ static void stli_waituntilsent(struct tty_struct *tty, int timeout) | |||
1938 | struct stliport *portp; | 1934 | struct stliport *portp; |
1939 | unsigned long tend; | 1935 | unsigned long tend; |
1940 | 1936 | ||
1941 | if (tty == NULL) | ||
1942 | return; | ||
1943 | portp = tty->driver_data; | 1937 | portp = tty->driver_data; |
1944 | if (portp == NULL) | 1938 | if (portp == NULL) |
1945 | return; | 1939 | return; |
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 308cb6014002..8beef50f95a0 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -616,9 +616,6 @@ static int mxser_set_baud(struct tty_struct *tty, long newspd) | |||
616 | int quot = 0, baud; | 616 | int quot = 0, baud; |
617 | unsigned char cval; | 617 | unsigned char cval; |
618 | 618 | ||
619 | if (!tty->termios) | ||
620 | return -1; | ||
621 | |||
622 | if (!info->ioaddr) | 619 | if (!info->ioaddr) |
623 | return -1; | 620 | return -1; |
624 | 621 | ||
@@ -688,8 +685,6 @@ static int mxser_change_speed(struct tty_struct *tty, | |||
688 | int ret = 0; | 685 | int ret = 0; |
689 | unsigned char status; | 686 | unsigned char status; |
690 | 687 | ||
691 | if (!tty->termios) | ||
692 | return ret; | ||
693 | cflag = tty->termios->c_cflag; | 688 | cflag = tty->termios->c_cflag; |
694 | if (!info->ioaddr) | 689 | if (!info->ioaddr) |
695 | return ret; | 690 | return ret; |
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c index ae377aa473ba..4a8215a89ad3 100644 --- a/drivers/char/n_r3964.c +++ b/drivers/char/n_r3964.c | |||
@@ -372,14 +372,8 @@ static void remove_from_rx_queue(struct r3964_info *pInfo, | |||
372 | static void put_char(struct r3964_info *pInfo, unsigned char ch) | 372 | static void put_char(struct r3964_info *pInfo, unsigned char ch) |
373 | { | 373 | { |
374 | struct tty_struct *tty = pInfo->tty; | 374 | struct tty_struct *tty = pInfo->tty; |
375 | |||
376 | if (tty == NULL) | ||
377 | return; | ||
378 | |||
379 | /* FIXME: put_char should not be called from an IRQ */ | 375 | /* FIXME: put_char should not be called from an IRQ */ |
380 | if (tty->ops->put_char) { | 376 | tty_put_char(tty, ch); |
381 | tty->ops->put_char(tty, ch); | ||
382 | } | ||
383 | pInfo->bcc ^= ch; | 377 | pInfo->bcc ^= ch; |
384 | } | 378 | } |
385 | 379 | ||
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index 81b3234127db..8b8f07a7f505 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -849,8 +849,6 @@ static void stl_flushbuffer(struct tty_struct *tty) | |||
849 | 849 | ||
850 | pr_debug("stl_flushbuffer(tty=%p)\n", tty); | 850 | pr_debug("stl_flushbuffer(tty=%p)\n", tty); |
851 | 851 | ||
852 | if (tty == NULL) | ||
853 | return; | ||
854 | portp = tty->driver_data; | 852 | portp = tty->driver_data; |
855 | if (portp == NULL) | 853 | if (portp == NULL) |
856 | return; | 854 | return; |
@@ -868,8 +866,6 @@ static void stl_waituntilsent(struct tty_struct *tty, int timeout) | |||
868 | 866 | ||
869 | pr_debug("stl_waituntilsent(tty=%p,timeout=%d)\n", tty, timeout); | 867 | pr_debug("stl_waituntilsent(tty=%p,timeout=%d)\n", tty, timeout); |
870 | 868 | ||
871 | if (tty == NULL) | ||
872 | return; | ||
873 | portp = tty->driver_data; | 869 | portp = tty->driver_data; |
874 | if (portp == NULL) | 870 | if (portp == NULL) |
875 | return; | 871 | return; |
@@ -1036,8 +1032,6 @@ static int stl_putchar(struct tty_struct *tty, unsigned char ch) | |||
1036 | 1032 | ||
1037 | pr_debug("stl_putchar(tty=%p,ch=%x)\n", tty, ch); | 1033 | pr_debug("stl_putchar(tty=%p,ch=%x)\n", tty, ch); |
1038 | 1034 | ||
1039 | if (tty == NULL) | ||
1040 | return -EINVAL; | ||
1041 | portp = tty->driver_data; | 1035 | portp = tty->driver_data; |
1042 | if (portp == NULL) | 1036 | if (portp == NULL) |
1043 | return -EINVAL; | 1037 | return -EINVAL; |
@@ -1073,8 +1067,6 @@ static void stl_flushchars(struct tty_struct *tty) | |||
1073 | 1067 | ||
1074 | pr_debug("stl_flushchars(tty=%p)\n", tty); | 1068 | pr_debug("stl_flushchars(tty=%p)\n", tty); |
1075 | 1069 | ||
1076 | if (tty == NULL) | ||
1077 | return; | ||
1078 | portp = tty->driver_data; | 1070 | portp = tty->driver_data; |
1079 | if (portp == NULL) | 1071 | if (portp == NULL) |
1080 | return; | 1072 | return; |
@@ -1093,8 +1085,6 @@ static int stl_writeroom(struct tty_struct *tty) | |||
1093 | 1085 | ||
1094 | pr_debug("stl_writeroom(tty=%p)\n", tty); | 1086 | pr_debug("stl_writeroom(tty=%p)\n", tty); |
1095 | 1087 | ||
1096 | if (tty == NULL) | ||
1097 | return 0; | ||
1098 | portp = tty->driver_data; | 1088 | portp = tty->driver_data; |
1099 | if (portp == NULL) | 1089 | if (portp == NULL) |
1100 | return 0; | 1090 | return 0; |
@@ -1125,8 +1115,6 @@ static int stl_charsinbuffer(struct tty_struct *tty) | |||
1125 | 1115 | ||
1126 | pr_debug("stl_charsinbuffer(tty=%p)\n", tty); | 1116 | pr_debug("stl_charsinbuffer(tty=%p)\n", tty); |
1127 | 1117 | ||
1128 | if (tty == NULL) | ||
1129 | return 0; | ||
1130 | portp = tty->driver_data; | 1118 | portp = tty->driver_data; |
1131 | if (portp == NULL) | 1119 | if (portp == NULL) |
1132 | return 0; | 1120 | return 0; |
@@ -1219,8 +1207,6 @@ static int stl_tiocmget(struct tty_struct *tty, struct file *file) | |||
1219 | { | 1207 | { |
1220 | struct stlport *portp; | 1208 | struct stlport *portp; |
1221 | 1209 | ||
1222 | if (tty == NULL) | ||
1223 | return -ENODEV; | ||
1224 | portp = tty->driver_data; | 1210 | portp = tty->driver_data; |
1225 | if (portp == NULL) | 1211 | if (portp == NULL) |
1226 | return -ENODEV; | 1212 | return -ENODEV; |
@@ -1236,8 +1222,6 @@ static int stl_tiocmset(struct tty_struct *tty, struct file *file, | |||
1236 | struct stlport *portp; | 1222 | struct stlport *portp; |
1237 | int rts = -1, dtr = -1; | 1223 | int rts = -1, dtr = -1; |
1238 | 1224 | ||
1239 | if (tty == NULL) | ||
1240 | return -ENODEV; | ||
1241 | portp = tty->driver_data; | 1225 | portp = tty->driver_data; |
1242 | if (portp == NULL) | 1226 | if (portp == NULL) |
1243 | return -ENODEV; | 1227 | return -ENODEV; |
@@ -1266,8 +1250,6 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd | |||
1266 | pr_debug("stl_ioctl(tty=%p,file=%p,cmd=%x,arg=%lx)\n", tty, file, cmd, | 1250 | pr_debug("stl_ioctl(tty=%p,file=%p,cmd=%x,arg=%lx)\n", tty, file, cmd, |
1267 | arg); | 1251 | arg); |
1268 | 1252 | ||
1269 | if (tty == NULL) | ||
1270 | return -ENODEV; | ||
1271 | portp = tty->driver_data; | 1253 | portp = tty->driver_data; |
1272 | if (portp == NULL) | 1254 | if (portp == NULL) |
1273 | return -ENODEV; | 1255 | return -ENODEV; |
@@ -1321,8 +1303,6 @@ static void stl_start(struct tty_struct *tty) | |||
1321 | 1303 | ||
1322 | pr_debug("stl_start(tty=%p)\n", tty); | 1304 | pr_debug("stl_start(tty=%p)\n", tty); |
1323 | 1305 | ||
1324 | if (tty == NULL) | ||
1325 | return; | ||
1326 | portp = tty->driver_data; | 1306 | portp = tty->driver_data; |
1327 | if (portp == NULL) | 1307 | if (portp == NULL) |
1328 | return; | 1308 | return; |
@@ -1338,8 +1318,6 @@ static void stl_settermios(struct tty_struct *tty, struct ktermios *old) | |||
1338 | 1318 | ||
1339 | pr_debug("stl_settermios(tty=%p,old=%p)\n", tty, old); | 1319 | pr_debug("stl_settermios(tty=%p,old=%p)\n", tty, old); |
1340 | 1320 | ||
1341 | if (tty == NULL) | ||
1342 | return; | ||
1343 | portp = tty->driver_data; | 1321 | portp = tty->driver_data; |
1344 | if (portp == NULL) | 1322 | if (portp == NULL) |
1345 | return; | 1323 | return; |
@@ -1373,8 +1351,6 @@ static void stl_throttle(struct tty_struct *tty) | |||
1373 | 1351 | ||
1374 | pr_debug("stl_throttle(tty=%p)\n", tty); | 1352 | pr_debug("stl_throttle(tty=%p)\n", tty); |
1375 | 1353 | ||
1376 | if (tty == NULL) | ||
1377 | return; | ||
1378 | portp = tty->driver_data; | 1354 | portp = tty->driver_data; |
1379 | if (portp == NULL) | 1355 | if (portp == NULL) |
1380 | return; | 1356 | return; |
@@ -1393,8 +1369,6 @@ static void stl_unthrottle(struct tty_struct *tty) | |||
1393 | 1369 | ||
1394 | pr_debug("stl_unthrottle(tty=%p)\n", tty); | 1370 | pr_debug("stl_unthrottle(tty=%p)\n", tty); |
1395 | 1371 | ||
1396 | if (tty == NULL) | ||
1397 | return; | ||
1398 | portp = tty->driver_data; | 1372 | portp = tty->driver_data; |
1399 | if (portp == NULL) | 1373 | if (portp == NULL) |
1400 | return; | 1374 | return; |
@@ -1414,8 +1388,6 @@ static void stl_stop(struct tty_struct *tty) | |||
1414 | 1388 | ||
1415 | pr_debug("stl_stop(tty=%p)\n", tty); | 1389 | pr_debug("stl_stop(tty=%p)\n", tty); |
1416 | 1390 | ||
1417 | if (tty == NULL) | ||
1418 | return; | ||
1419 | portp = tty->driver_data; | 1391 | portp = tty->driver_data; |
1420 | if (portp == NULL) | 1392 | if (portp == NULL) |
1421 | return; | 1393 | return; |
@@ -1436,8 +1408,6 @@ static void stl_hangup(struct tty_struct *tty) | |||
1436 | 1408 | ||
1437 | pr_debug("stl_hangup(tty=%p)\n", tty); | 1409 | pr_debug("stl_hangup(tty=%p)\n", tty); |
1438 | 1410 | ||
1439 | if (tty == NULL) | ||
1440 | return; | ||
1441 | portp = tty->driver_data; | 1411 | portp = tty->driver_data; |
1442 | if (portp == NULL) | 1412 | if (portp == NULL) |
1443 | return; | 1413 | return; |
@@ -1470,8 +1440,6 @@ static int stl_breakctl(struct tty_struct *tty, int state) | |||
1470 | 1440 | ||
1471 | pr_debug("stl_breakctl(tty=%p,state=%d)\n", tty, state); | 1441 | pr_debug("stl_breakctl(tty=%p,state=%d)\n", tty, state); |
1472 | 1442 | ||
1473 | if (tty == NULL) | ||
1474 | return -EINVAL; | ||
1475 | portp = tty->driver_data; | 1443 | portp = tty->driver_data; |
1476 | if (portp == NULL) | 1444 | if (portp == NULL) |
1477 | return -EINVAL; | 1445 | return -EINVAL; |
@@ -1488,8 +1456,6 @@ static void stl_sendxchar(struct tty_struct *tty, char ch) | |||
1488 | 1456 | ||
1489 | pr_debug("stl_sendxchar(tty=%p,ch=%x)\n", tty, ch); | 1457 | pr_debug("stl_sendxchar(tty=%p,ch=%x)\n", tty, ch); |
1490 | 1458 | ||
1491 | if (tty == NULL) | ||
1492 | return; | ||
1493 | portp = tty->driver_data; | 1459 | portp = tty->driver_data; |
1494 | if (portp == NULL) | 1460 | if (portp == NULL) |
1495 | return; | 1461 | return; |