summaryrefslogtreecommitdiffstats
path: root/drivers/tty/hvc/hvc_udbg.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2012-03-14 08:37:04 +0100
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2012-03-15 23:28:15 +0100
commit7d3d897a4697e4ff746e5e82f116b2346ed28150 (patch)
tree740b5a83f9d354edf255f44a6072a47ec1ff7ba0 /drivers/tty/hvc/hvc_udbg.c
parentpowerpc: Remove some of the legacy iSeries specific device drivers (diff)
downloadlinux-7d3d897a4697e4ff746e5e82f116b2346ed28150.tar.xz
linux-7d3d897a4697e4ff746e5e82f116b2346ed28150.zip
powerpc/hvc_udbg: Don't crash when udbg_putc is NULL
Also while at it, add some help text indicating why you shouldn't enable that driver under normal circumstances Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/tty/hvc/hvc_udbg.c')
-rw-r--r--drivers/tty/hvc/hvc_udbg.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/tty/hvc/hvc_udbg.c b/drivers/tty/hvc/hvc_udbg.c
index b0957e61a7be..2259c6e72f06 100644
--- a/drivers/tty/hvc/hvc_udbg.c
+++ b/drivers/tty/hvc/hvc_udbg.c
@@ -36,7 +36,7 @@ static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count)
{
int i;
- for (i = 0; i < count; i++)
+ for (i = 0; i < count && udbg_putc; i++)
udbg_putc(buf[i]);
return i;
@@ -67,6 +67,9 @@ static int __init hvc_udbg_init(void)
{
struct hvc_struct *hp;
+ if (!udbg_putc)
+ return -ENODEV;
+
BUG_ON(hvc_udbg_dev);
hp = hvc_alloc(0, NO_IRQ, &hvc_udbg_ops, 16);
@@ -88,6 +91,9 @@ module_exit(hvc_udbg_exit);
static int __init hvc_udbg_console_init(void)
{
+ if (!udbg_putc)
+ return -ENODEV;
+
hvc_instantiate(0, 0, &hvc_udbg_ops);
add_preferred_console("hvc", 0, NULL);