linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] tty: add a check for NULL in con_init
       [not found] <1608551264-26117-1-git-send-email-zhangqiumiao1@huwei.com>
@ 2020-12-21 12:13 ` Greg KH
  0 siblings, 0 replies; only message in thread
From: Greg KH @ 2020-12-21 12:13 UTC (permalink / raw)
  To: zhangqiumiao1; +Cc: jirislaby, linux-kernel, zhangqiumiao

On Mon, Dec 21, 2020 at 07:47:44PM +0800, zhangqiumiao1@huwei.com wrote:
> From: zhangqiumiao <zhangqiumiao1@huawei.com>
> 
> Add a check for NULL in con_init in order to make sure kzalloc succeeds.
> 
> Signed-off-by: zhangqiumiao <zhangqiumiao1@huawei.com>
> ---
>  drivers/tty/vt/vt.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index d04a162939a4..916f3370a136 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -3486,11 +3486,15 @@ static int __init con_init(void)
> 
>  	for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
>  		vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
> +		if (!vc)
> +			return -ENOMEM;
>  		INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
>  		tty_port_init(&vc->port);
>  		visual_init(vc, currcons, 1);
>  		/* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */
>  		vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
> +		if (!vc->vc_screenbuf)
> +			return -ENOMEM;

Did you try to see what happens if you ever trigger this?

Did you trigger this in real-world situations?

Have you read the old email threads about where people tried to "fix"
this and the problems that ended up happening?  If not, please do so...

Hint, I can not take this as you will NEVER hit this in a real system.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-21 12:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1608551264-26117-1-git-send-email-zhangqiumiao1@huwei.com>
2020-12-21 12:13 ` [PATCH] tty: add a check for NULL in con_init Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).