Commit afff7621 authored by Sebastian Ott's avatar Sebastian Ott Committed by Jiri Slaby

s390/cio: fix driver callback initialization for ccw consoles

commit 2253e8d7 upstream.

ccw consoles are in use before they can be properly registered with
the driver core. For devices which are in use by a device driver we
rely on the ccw_device's pointer to the driver callbacks to be valid.
For ccw consoles this pointer is NULL until they are registered later
during boot and we dereferenced this pointer. This worked by
chance on 64 bit builds (cdev->drv was NULL but the optional callback
cdev->drv->path_event was also NULL by coincidence) and was unnoticed
until we received reports about boot failures on 31 bit systems.
Fix it by initializing the driver pointer for ccw consoles.
Reported-by: default avatarMike Frysinger <vapier@gentoo.org>
Reported-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Reviewed-by: default avatarPeter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent e3f6483f
...@@ -219,7 +219,7 @@ extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *); ...@@ -219,7 +219,7 @@ extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
#define to_ccwdev(n) container_of(n, struct ccw_device, dev) #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
#define to_ccwdrv(n) container_of(n, struct ccw_driver, driver) #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
extern struct ccw_device *ccw_device_probe_console(void); extern struct ccw_device *ccw_device_probe_console(struct ccw_driver *);
extern void ccw_device_wait_idle(struct ccw_device *); extern void ccw_device_wait_idle(struct ccw_device *);
extern int ccw_device_force_console(struct ccw_device *); extern int ccw_device_force_console(struct ccw_device *);
......
...@@ -922,7 +922,7 @@ static int __init con3215_init(void) ...@@ -922,7 +922,7 @@ static int __init con3215_init(void)
raw3215_freelist = req; raw3215_freelist = req;
} }
cdev = ccw_device_probe_console(); cdev = ccw_device_probe_console(&raw3215_ccw_driver);
if (IS_ERR(cdev)) if (IS_ERR(cdev))
return -ENODEV; return -ENODEV;
......
...@@ -576,7 +576,6 @@ static struct console con3270 = { ...@@ -576,7 +576,6 @@ static struct console con3270 = {
static int __init static int __init
con3270_init(void) con3270_init(void)
{ {
struct ccw_device *cdev;
struct raw3270 *rp; struct raw3270 *rp;
void *cbuf; void *cbuf;
int i; int i;
...@@ -591,10 +590,7 @@ con3270_init(void) ...@@ -591,10 +590,7 @@ con3270_init(void)
cpcmd("TERM AUTOCR OFF", NULL, 0, NULL); cpcmd("TERM AUTOCR OFF", NULL, 0, NULL);
} }
cdev = ccw_device_probe_console(); rp = raw3270_setup_console();
if (IS_ERR(cdev))
return -ENODEV;
rp = raw3270_setup_console(cdev);
if (IS_ERR(rp)) if (IS_ERR(rp))
return PTR_ERR(rp); return PTR_ERR(rp);
......
...@@ -776,16 +776,24 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc) ...@@ -776,16 +776,24 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
} }
#ifdef CONFIG_TN3270_CONSOLE #ifdef CONFIG_TN3270_CONSOLE
/* Tentative definition - see below for actual definition. */
static struct ccw_driver raw3270_ccw_driver;
/* /*
* Setup 3270 device configured as console. * Setup 3270 device configured as console.
*/ */
struct raw3270 __init *raw3270_setup_console(struct ccw_device *cdev) struct raw3270 __init *raw3270_setup_console(void)
{ {
struct ccw_device *cdev;
unsigned long flags; unsigned long flags;
struct raw3270 *rp; struct raw3270 *rp;
char *ascebc; char *ascebc;
int rc; int rc;
cdev = ccw_device_probe_console(&raw3270_ccw_driver);
if (IS_ERR(cdev))
return ERR_CAST(cdev);
rp = kzalloc(sizeof(struct raw3270), GFP_KERNEL | GFP_DMA); rp = kzalloc(sizeof(struct raw3270), GFP_KERNEL | GFP_DMA);
ascebc = kzalloc(256, GFP_KERNEL); ascebc = kzalloc(256, GFP_KERNEL);
rc = raw3270_setup_device(cdev, rp, ascebc); rc = raw3270_setup_device(cdev, rp, ascebc);
......
...@@ -190,7 +190,7 @@ raw3270_put_view(struct raw3270_view *view) ...@@ -190,7 +190,7 @@ raw3270_put_view(struct raw3270_view *view)
wake_up(&raw3270_wait_queue); wake_up(&raw3270_wait_queue);
} }
struct raw3270 *raw3270_setup_console(struct ccw_device *cdev); struct raw3270 *raw3270_setup_console(void);
void raw3270_wait_cons_dev(struct raw3270 *); void raw3270_wait_cons_dev(struct raw3270 *);
/* Notifier for device addition/removal */ /* Notifier for device addition/removal */
......
...@@ -1610,7 +1610,7 @@ static int ccw_device_console_enable(struct ccw_device *cdev, ...@@ -1610,7 +1610,7 @@ static int ccw_device_console_enable(struct ccw_device *cdev,
return rc; return rc;
} }
struct ccw_device *ccw_device_probe_console(void) struct ccw_device *ccw_device_probe_console(struct ccw_driver *drv)
{ {
struct io_subchannel_private *io_priv; struct io_subchannel_private *io_priv;
struct ccw_device *cdev; struct ccw_device *cdev;
...@@ -1632,6 +1632,7 @@ struct ccw_device *ccw_device_probe_console(void) ...@@ -1632,6 +1632,7 @@ struct ccw_device *ccw_device_probe_console(void)
kfree(io_priv); kfree(io_priv);
return cdev; return cdev;
} }
cdev->drv = drv;
set_io_private(sch, io_priv); set_io_private(sch, io_priv);
ret = ccw_device_console_enable(cdev, sch); ret = ccw_device_console_enable(cdev, sch);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment