From: Andy Whitcroft If device->num is zero we attempt to kmalloc() zero bytes. When SLUB is enabled this returns a null pointer and take that as an allocation failure and fail the device register. Check for no devices and avoid the allocation. [akpm: opportunistic kzalloc() conversion] Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton --- drivers/char/tty_io.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff -puN drivers/char/tty_io.c~tty_register_driver-only-allocate-tty-instances-when-defined drivers/char/tty_io.c --- a/drivers/char/tty_io.c~tty_register_driver-only-allocate-tty-instances-when-defined +++ a/drivers/char/tty_io.c @@ -3720,11 +3720,10 @@ int tty_register_driver(struct tty_drive if (driver->flags & TTY_DRIVER_INSTALLED) return 0; - if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) { - p = kmalloc(driver->num * 3 * sizeof(void *), GFP_KERNEL); + if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM) && driver->num) { + p = kzalloc(driver->num * 3 * sizeof(void *), GFP_KERNEL); if (!p) return -ENOMEM; - memset(p, 0, driver->num * 3 * sizeof(void *)); } if (!driver->major) { _