s390/sclp_vt220: Fix kernel panic due to early terminal input
authorPeter Oberparleiter <oberpar@linux.vnet.ibm.com>
Wed, 9 Apr 2014 11:10:05 +0000 (13:10 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 11 Apr 2014 11:53:38 +0000 (13:53 +0200)
A kernel panic might occur when there is terminal input available via
the SCLP VT220 interface at an early time during the boot process.

The processing of terminal input requires prior initialization which is
done via an early_initcall function (init_workqueues) while the SCLP
VT220 driver registers for terminal input during a console_initcall
function (sclp_vt220_con_init). When there is terminal input available
via the SCLP interface between console_initcall and early_initcall, a
null pointer dereference occurs (system_wq is null).

Fix this problem by moving the registration for terminal input to a
device_initcall function (sclp_vt220_tty_init).

Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/char/sclp_vt220.c

index 4eed38cd0af629b87108289174a81a9c5dedb44c..cd9c919095966b271fb0dee6a6dfdd49d176e022 100644 (file)
@@ -97,13 +97,16 @@ static void sclp_vt220_pm_event_fn(struct sclp_register *reg,
 static int __sclp_vt220_emit(struct sclp_vt220_request *request);
 static void sclp_vt220_emit_current(void);
 
-/* Registration structure for our interest in SCLP event buffers */
+/* Registration structure for SCLP output event buffers */
 static struct sclp_register sclp_vt220_register = {
        .send_mask              = EVTYP_VT220MSG_MASK,
+       .pm_event_fn            = sclp_vt220_pm_event_fn,
+};
+
+/* Registration structure for SCLP input event buffers */
+static struct sclp_register sclp_vt220_register_input = {
        .receive_mask           = EVTYP_VT220MSG_MASK,
-       .state_change_fn        = NULL,
        .receiver_fn            = sclp_vt220_receiver_fn,
-       .pm_event_fn            = sclp_vt220_pm_event_fn,
 };
 
 
@@ -715,9 +718,14 @@ static int __init sclp_vt220_tty_init(void)
        rc = tty_register_driver(driver);
        if (rc)
                goto out_init;
+       rc = sclp_register(&sclp_vt220_register_input);
+       if (rc)
+               goto out_reg;
        sclp_vt220_driver = driver;
        return 0;
 
+out_reg:
+       tty_unregister_driver(driver);
 out_init:
        __sclp_vt220_cleanup();
 out_driver: