Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Cox and committed by
Linus Torvalds
51383f69 ea1afd25

+1 -79
-6
drivers/char/amiserial.c
··· 837 837 struct async_struct *info; 838 838 unsigned long flags; 839 839 840 - if (!tty) 841 - return 0; 842 - 843 840 info = tty->driver_data; 844 841 845 842 if (serial_paranoia_check(info, tty->name, "rs_put_char")) ··· 888 891 int c, ret = 0; 889 892 struct async_struct *info; 890 893 unsigned long flags; 891 - 892 - if (!tty) 893 - return 0; 894 894 895 895 info = tty->driver_data; 896 896
-21
drivers/char/generic_serial.c
··· 54 54 55 55 func_enter (); 56 56 57 - if (!tty) return 0; 58 - 59 57 port = tty->driver_data; 60 58 61 59 if (!port) return 0; ··· 94 96 int t; 95 97 96 98 func_enter (); 97 - 98 - if (!tty) return 0; 99 99 100 100 port = tty->driver_data; 101 101 ··· 181 185 struct gs_port *port; 182 186 func_enter (); 183 187 184 - if (!tty) return 0; 185 188 port = tty->driver_data; 186 189 187 190 if (!port->rd) return 0; ··· 269 274 270 275 func_enter (); 271 276 272 - if (!tty) return; 273 - 274 277 port = tty->driver_data; 275 278 276 279 if (!port) return; ··· 288 295 struct gs_port *port; 289 296 290 297 func_enter (); 291 - 292 - if (!tty) return; 293 298 294 299 port = tty->driver_data; 295 300 ··· 312 321 313 322 func_enter (); 314 323 315 - if (!tty) return; 316 - 317 324 port = tty->driver_data; 318 325 319 326 if (!port) return; ··· 329 340 void gs_start(struct tty_struct * tty) 330 341 { 331 342 struct gs_port *port; 332 - 333 - if (!tty) return; 334 343 335 344 port = tty->driver_data; 336 345 ··· 380 393 381 394 func_enter (); 382 395 383 - if (!tty) return; 384 - 385 396 port = tty->driver_data; 386 397 tty = port->port.tty; 387 398 if (!tty) ··· 410 425 if (!port) return 0; 411 426 412 427 tty = port->port.tty; 413 - 414 - if (!tty) return 0; 415 428 416 429 gs_dprintk (GS_DEBUG_BTR, "Entering gs_block_till_ready.\n"); 417 430 /* ··· 506 523 507 524 func_enter (); 508 525 509 - if (!tty) return; 510 - 511 526 port = (struct gs_port *) tty->driver_data; 512 527 513 528 if (!port) return; ··· 601 620 struct ktermios *tiosp; 602 621 603 622 func_enter(); 604 - 605 - if (!tty) return; 606 623 607 624 port = tty->driver_data; 608 625
-6
drivers/char/istallion.c
··· 1375 1375 stli_txcookrealsize = 0; 1376 1376 stli_txcooktty = NULL; 1377 1377 1378 - if (tty == NULL) 1379 - return; 1380 1378 if (cooktty == NULL) 1381 1379 return; 1382 1380 if (tty != cooktty) ··· 1730 1732 struct ktermios *tiosp; 1731 1733 asyport_t aport; 1732 1734 1733 - if (tty == NULL) 1734 - return; 1735 1735 portp = tty->driver_data; 1736 1736 if (portp == NULL) 1737 1737 return; ··· 1934 1938 struct stliport *portp; 1935 1939 unsigned long tend; 1936 1940 1937 - if (tty == NULL) 1938 - return; 1939 1941 portp = tty->driver_data; 1940 1942 if (portp == NULL) 1941 1943 return;
-5
drivers/char/mxser.c
··· 616 616 int quot = 0, baud; 617 617 unsigned char cval; 618 618 619 - if (!tty->termios) 620 - return -1; 621 - 622 619 if (!info->ioaddr) 623 620 return -1; 624 621 ··· 685 688 int ret = 0; 686 689 unsigned char status; 687 690 688 - if (!tty->termios) 689 - return ret; 690 691 cflag = tty->termios->c_cflag; 691 692 if (!info->ioaddr) 692 693 return ret;
+1 -7
drivers/char/n_r3964.c
··· 372 372 static void put_char(struct r3964_info *pInfo, unsigned char ch) 373 373 { 374 374 struct tty_struct *tty = pInfo->tty; 375 - 376 - if (tty == NULL) 377 - return; 378 - 379 375 /* FIXME: put_char should not be called from an IRQ */ 380 - if (tty->ops->put_char) { 381 - tty->ops->put_char(tty, ch); 382 - } 376 + tty_put_char(tty, ch); 383 377 pInfo->bcc ^= ch; 384 378 } 385 379
-34
drivers/char/stallion.c
··· 849 849 850 850 pr_debug("stl_flushbuffer(tty=%p)\n", tty); 851 851 852 - if (tty == NULL) 853 - return; 854 852 portp = tty->driver_data; 855 853 if (portp == NULL) 856 854 return; ··· 866 868 867 869 pr_debug("stl_waituntilsent(tty=%p,timeout=%d)\n", tty, timeout); 868 870 869 - if (tty == NULL) 870 - return; 871 871 portp = tty->driver_data; 872 872 if (portp == NULL) 873 873 return; ··· 1032 1036 1033 1037 pr_debug("stl_putchar(tty=%p,ch=%x)\n", tty, ch); 1034 1038 1035 - if (tty == NULL) 1036 - return -EINVAL; 1037 1039 portp = tty->driver_data; 1038 1040 if (portp == NULL) 1039 1041 return -EINVAL; ··· 1067 1073 1068 1074 pr_debug("stl_flushchars(tty=%p)\n", tty); 1069 1075 1070 - if (tty == NULL) 1071 - return; 1072 1076 portp = tty->driver_data; 1073 1077 if (portp == NULL) 1074 1078 return; ··· 1085 1093 1086 1094 pr_debug("stl_writeroom(tty=%p)\n", tty); 1087 1095 1088 - if (tty == NULL) 1089 - return 0; 1090 1096 portp = tty->driver_data; 1091 1097 if (portp == NULL) 1092 1098 return 0; ··· 1115 1125 1116 1126 pr_debug("stl_charsinbuffer(tty=%p)\n", tty); 1117 1127 1118 - if (tty == NULL) 1119 - return 0; 1120 1128 portp = tty->driver_data; 1121 1129 if (portp == NULL) 1122 1130 return 0; ··· 1207 1219 { 1208 1220 struct stlport *portp; 1209 1221 1210 - if (tty == NULL) 1211 - return -ENODEV; 1212 1222 portp = tty->driver_data; 1213 1223 if (portp == NULL) 1214 1224 return -ENODEV; ··· 1222 1236 struct stlport *portp; 1223 1237 int rts = -1, dtr = -1; 1224 1238 1225 - if (tty == NULL) 1226 - return -ENODEV; 1227 1239 portp = tty->driver_data; 1228 1240 if (portp == NULL) 1229 1241 return -ENODEV; ··· 1250 1266 pr_debug("stl_ioctl(tty=%p,file=%p,cmd=%x,arg=%lx)\n", tty, file, cmd, 1251 1267 arg); 1252 1268 1253 - if (tty == NULL) 1254 - return -ENODEV; 1255 1269 portp = tty->driver_data; 1256 1270 if (portp == NULL) 1257 1271 return -ENODEV; ··· 1303 1321 1304 1322 pr_debug("stl_start(tty=%p)\n", tty); 1305 1323 1306 - if (tty == NULL) 1307 - return; 1308 1324 portp = tty->driver_data; 1309 1325 if (portp == NULL) 1310 1326 return; ··· 1318 1338 1319 1339 pr_debug("stl_settermios(tty=%p,old=%p)\n", tty, old); 1320 1340 1321 - if (tty == NULL) 1322 - return; 1323 1341 portp = tty->driver_data; 1324 1342 if (portp == NULL) 1325 1343 return; ··· 1351 1373 1352 1374 pr_debug("stl_throttle(tty=%p)\n", tty); 1353 1375 1354 - if (tty == NULL) 1355 - return; 1356 1376 portp = tty->driver_data; 1357 1377 if (portp == NULL) 1358 1378 return; ··· 1369 1393 1370 1394 pr_debug("stl_unthrottle(tty=%p)\n", tty); 1371 1395 1372 - if (tty == NULL) 1373 - return; 1374 1396 portp = tty->driver_data; 1375 1397 if (portp == NULL) 1376 1398 return; ··· 1388 1414 1389 1415 pr_debug("stl_stop(tty=%p)\n", tty); 1390 1416 1391 - if (tty == NULL) 1392 - return; 1393 1417 portp = tty->driver_data; 1394 1418 if (portp == NULL) 1395 1419 return; ··· 1408 1436 1409 1437 pr_debug("stl_hangup(tty=%p)\n", tty); 1410 1438 1411 - if (tty == NULL) 1412 - return; 1413 1439 portp = tty->driver_data; 1414 1440 if (portp == NULL) 1415 1441 return; ··· 1440 1470 1441 1471 pr_debug("stl_breakctl(tty=%p,state=%d)\n", tty, state); 1442 1472 1443 - if (tty == NULL) 1444 - return -EINVAL; 1445 1473 portp = tty->driver_data; 1446 1474 if (portp == NULL) 1447 1475 return -EINVAL; ··· 1456 1488 1457 1489 pr_debug("stl_sendxchar(tty=%p,ch=%x)\n", tty, ch); 1458 1490 1459 - if (tty == NULL) 1460 - return; 1461 1491 portp = tty->driver_data; 1462 1492 if (portp == NULL) 1463 1493 return;