Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=543691a6cd70b606dd9bed5e77b120c5d9c5c506 Commit: 543691a6cd70b606dd9bed5e77b120c5d9c5c506 Parent: b5637e65ee2cecd344b1f8ff750013f697d3ae16 Author: Andy Whitcroft <[EMAIL PROTECTED]> AuthorDate: Sun May 6 14:49:33 2007 -0700 Committer: Linus Torvalds <[EMAIL PROTECTED]> CommitDate: Mon May 7 12:12:53 2007 -0700
tty_register_driver: only allocate tty instances when defined 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 <[EMAIL PROTECTED]> Signed-off-by: Andrew Morton <[EMAIL PROTECTED]> Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]> --- drivers/char/tty_io.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 7a32df5..389da36 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -3720,11 +3720,10 @@ int tty_register_driver(struct tty_driver *driver) 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) { - To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html