2014-07-23 06:06:29

by Yoshihiro YUNOMAE

[permalink] [raw]
Subject: [PATCH] serial/core: Fix too big allocation for attribute member

Current code allocates too much data for tty_groups member of uart_port struct,
so fix it.

Signed-off-by: Yoshihiro YUNOMAE <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: Dan Carpenter <[email protected]>
---
drivers/tty/serial/serial_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 4af764c..8ded213 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2617,7 +2617,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
if (uport->attr_group)
num_groups++;

- uport->tty_groups = kcalloc(num_groups, sizeof(**uport->tty_groups),
+ uport->tty_groups = kcalloc(num_groups, sizeof(*uport->tty_groups),
GFP_KERNEL);
if (!uport->tty_groups) {
ret = -ENOMEM;


2014-07-23 08:10:42

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH] serial/core: Fix too big allocation for attribute member

On 23/07/14 07:06, Yoshihiro YUNOMAE wrote:
> Current code allocates too much data for tty_groups member of uart_port struct,
> so fix it.
>
> Signed-off-by: Yoshihiro YUNOMAE <[email protected]>
> CC: Greg Kroah-Hartman <[email protected]>
> CC: Dan Carpenter <[email protected]>

Reviewed-by: Daniel Thompson <[email protected]>

(using linux-next tree for context).