Skip to content

Commit ce3da1a

Browse files
George Spelvingregkh
authored andcommitted
pps: Don't crash the machine when exiting will do
PPS is not really the must-have subsystem that warrants crashing the machine if the ldisc interface is broken. Signed-off-by: Peter Hurley <[email protected]> Signed-off-by: George Spelvin <[email protected]> Acked-by: Rodolfo Giometti <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d953e0e commit ce3da1a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/pps/clients/pps-ldisc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/serial_core.h>
2626
#include <linux/tty.h>
2727
#include <linux/pps_kernel.h>
28+
#include <linux/bug.h>
2829

2930
#define PPS_TTY_MAGIC 0x0001
3031

@@ -33,7 +34,12 @@ static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status,
3334
{
3435
struct pps_device *pps = pps_lookup_dev(tty);
3536

36-
BUG_ON(pps == NULL);
37+
/*
38+
* This should never fail, but the ldisc locking is very
39+
* convoluted, so don't crash just in case.
40+
*/
41+
if (WARN_ON_ONCE(pps == NULL))
42+
return;
3743

3844
/* Now do the PPS event report */
3945
pps_event(pps, ts, status ? PPS_CAPTUREASSERT :
@@ -93,6 +99,9 @@ static void pps_tty_close(struct tty_struct *tty)
9399

94100
alias_n_tty_close(tty);
95101

102+
if (WARN_ON(!pps))
103+
return;
104+
96105
dev_info(pps->dev, "removed\n");
97106
pps_unregister_source(pps);
98107
}

0 commit comments

Comments
 (0)