According to the comment in struct tty, t_modem is optional; hence we should
guard against NULL t_modem entry. Otherwise, driver doesn't have t_modem callback implemented(such like sys/dev/usb/ucycom.c) would panic when someone opens the driver's associated tty device. Reviewed by: phk, sam (mentor)
This commit is contained in:
parent
365971ecad
commit
2d4420789d
@ -3134,7 +3134,8 @@ ttyopen(struct cdev *dev, int flag, int mode, struct thread *td)
|
||||
*/
|
||||
tp->t_termios = ISCALLOUT(dev) ? tp->t_init_out : tp->t_init_in;
|
||||
tp->t_cflag = tp->t_termios.c_cflag;
|
||||
tp->t_modem(tp, SER_DTR | SER_RTS, 0);
|
||||
if (tp->t_modem != NULL)
|
||||
tp->t_modem(tp, SER_DTR | SER_RTS, 0);
|
||||
++tp->t_wopeners;
|
||||
error = tp->t_param(tp, &tp->t_termios);
|
||||
--tp->t_wopeners;
|
||||
@ -3142,7 +3143,8 @@ ttyopen(struct cdev *dev, int flag, int mode, struct thread *td)
|
||||
error = tp->t_open(tp, dev);
|
||||
if (error != 0)
|
||||
goto out;
|
||||
if (ISCALLOUT(dev) || (tp->t_modem(tp, 0, 0) & SER_DCD))
|
||||
if (ISCALLOUT(dev) || (tp->t_modem != NULL &&
|
||||
(tp->t_modem(tp, 0, 0) & SER_DCD)))
|
||||
ttyld_modem(tp, 1);
|
||||
}
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user