Re: [PATCH] VirtioConsole support.

From: Joe Perches
Date: Fri Oct 28 2011 - 11:35:24 EST


On Thu, 2011-10-27 at 14:43 -0700, Miche Baker-Harvey wrote:
> Multiple HVC console terminals enabled.

Just a note on allocation.

> diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
[]
> @@ -845,6 +857,19 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
> kref_init(&hp->kref);
>
> INIT_WORK(&hp->tty_resize, hvc_set_winsz);
> + /*
> + * make each console its own struct console.
> + * No need to do allocation and copy under lock.
> + */
> + cp = kzalloc(sizeof(*cp), GFP_KERNEL);
> + if (!cp) {
> + kfree(hp);
> + mutex_unlock(&hvc_ports_mutex);
> + return ERR_PTR(-ENOMEM);
> + }
> + memcpy(cp, &hvc_console, sizeof(*cp));

The kzalloc should be kmalloc as the allocated
memory is immediately overwritten.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/