]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
pps: Don't crash the machine when exiting will do
authorGeorge Spelvin <linux@horizon.com>
Sun, 10 Feb 2013 09:43:41 +0000 (04:43 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Feb 2013 17:43:07 +0000 (09:43 -0800)
PPS is not really the must-have subsystem that warrants crashing
the machine if the ldisc interface is broken.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: George Spelvin <linux@horizon.com>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pps/clients/pps-ldisc.c

index 60cee9e0ecb36099c9c4a41a2cb20feeb11e28ff..a94f73e1480d0e5b3c45eee167fdc95a3f1303c2 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/serial_core.h>
 #include <linux/tty.h>
 #include <linux/pps_kernel.h>
+#include <linux/bug.h>
 
 #define PPS_TTY_MAGIC          0x0001
 
@@ -33,7 +34,12 @@ static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status,
 {
        struct pps_device *pps = pps_lookup_dev(tty);
 
-       BUG_ON(pps == NULL);
+       /*
+        * 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 :
@@ -93,6 +99,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);
 }