mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 19:08:58 +00:00
Don't follow null pointers if we somehow have a null devswitch entry
despite having a non-null cn_tab entry. This case now works the same as if there is no physical console, except i/o at the kernel printf level may still work. This frees drivers of physical console drivers from the responsibility of attaching the device no matter what.
This commit is contained in:
parent
be16a3aba0
commit
f4675a30ed
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56582
@ -165,10 +165,12 @@ cninit_finish()
|
||||
* Hook the open and close functions.
|
||||
*/
|
||||
cdp = devsw(cn_tab->cn_dev);
|
||||
if (cdp != NULL) {
|
||||
cn_phys_close = cdp->d_close;
|
||||
cdp->d_close = cnclose;
|
||||
cn_phys_open = cdp->d_open;
|
||||
cdp->d_open = cnopen;
|
||||
}
|
||||
cn_dev_t = cn_tab->cn_dev;
|
||||
cn_udev_t = dev2udev(cn_dev_t);
|
||||
}
|
||||
@ -185,9 +187,11 @@ cnuninit(void)
|
||||
* Unhook the open and close functions.
|
||||
*/
|
||||
cdp = devsw(cn_tab->cn_dev);
|
||||
if (cdp != NULL) {
|
||||
cdp->d_close = cn_phys_close;
|
||||
cn_phys_close = NULL;
|
||||
cdp->d_open = cn_phys_open;
|
||||
}
|
||||
cn_phys_close = NULL;
|
||||
cn_phys_open = NULL;
|
||||
cn_dev_t = NODEV;
|
||||
cn_udev_t = NOUDEV;
|
||||
@ -250,7 +254,7 @@ cnopen(dev, flag, mode, p)
|
||||
dev_t cndev, physdev;
|
||||
int retval = 0;
|
||||
|
||||
if (cn_tab == NULL)
|
||||
if (cn_tab == NULL || cn_phys_open == NULL)
|
||||
return (0);
|
||||
cndev = cn_tab->cn_dev;
|
||||
physdev = (major(dev) == major(cndev) ? dev : cndev);
|
||||
@ -287,7 +291,7 @@ cnclose(dev, flag, mode, p)
|
||||
dev_t cndev;
|
||||
struct tty *cn_tp;
|
||||
|
||||
if (cn_tab == NULL)
|
||||
if (cn_tab == NULL || cn_phys_open == NULL)
|
||||
return (0);
|
||||
cndev = cn_tab->cn_dev;
|
||||
cn_tp = cndev->si_tty;
|
||||
@ -327,7 +331,8 @@ cnread(dev, uio, flag)
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
if ((cn_tab == NULL) || cn_mute)
|
||||
|
||||
if (cn_tab == NULL || cn_phys_open == NULL)
|
||||
return (0);
|
||||
dev = cn_tab->cn_dev;
|
||||
return ((*devsw(dev)->d_read)(dev, uio, flag));
|
||||
@ -339,7 +344,8 @@ cnwrite(dev, uio, flag)
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
if ((cn_tab == NULL) || cn_mute) {
|
||||
|
||||
if (cn_tab == NULL || cn_phys_open == NULL) {
|
||||
uio->uio_resid = 0; /* dump the data */
|
||||
return (0);
|
||||
}
|
||||
@ -360,7 +366,7 @@ cnioctl(dev, cmd, data, flag, p)
|
||||
{
|
||||
int error;
|
||||
|
||||
if ((cn_tab == NULL) || cn_mute)
|
||||
if (cn_tab == NULL || cn_phys_open == NULL)
|
||||
return (0);
|
||||
/*
|
||||
* Superuser can always use this to wrest control of console
|
||||
|
Loading…
Reference in New Issue
Block a user