diff options
Diffstat (limited to 'drivers/pps/clients/pps-ldisc.c')
| -rw-r--r-- | drivers/pps/clients/pps-ldisc.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c index 60cee9e0ecb..73bd3bb4d93 100644 --- a/drivers/pps/clients/pps-ldisc.c +++ b/drivers/pps/clients/pps-ldisc.c @@ -25,18 +25,27 @@ #include <linux/serial_core.h> #include <linux/tty.h> #include <linux/pps_kernel.h> +#include <linux/bug.h> #define PPS_TTY_MAGIC 0x0001 -static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, - struct pps_event_time *ts) +static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status) { - struct pps_device *pps = pps_lookup_dev(tty); + struct pps_device *pps; + struct pps_event_time ts; - BUG_ON(pps == NULL); + pps_get_ts(&ts); + + pps = pps_lookup_dev(tty); + /* + * This should never fail, but the ldisc locking is very + * convoluted, so don't crash just in case. + */ + if (WARN_ON_ONCE(pps == NULL)) + return; /* Now do the PPS event report */ - pps_event(pps, ts, status ? PPS_CAPTUREASSERT : + pps_event(pps, &ts, status ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR, NULL); dev_dbg(pps->dev, "PPS %s at %lu\n", @@ -93,6 +102,9 @@ static void pps_tty_close(struct tty_struct *tty) alias_n_tty_close(tty); + if (WARN_ON(!pps)) + return; + dev_info(pps->dev, "removed\n"); pps_unregister_source(pps); } |
