All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: zhangqiumiao1@huwei.com
Cc: jirislaby@kernel.org, linux-kernel@vger.kernel.org,
	zhangqiumiao <zhangqiumiao1@huawei.com>
Subject: Re: [PATCH] tty: add a check for NULL in con_init
Date: Mon, 21 Dec 2020 13:13:02 +0100	[thread overview]
Message-ID: <X+CRTqDQwVYSZQBi@kroah.com> (raw)
In-Reply-To: <1608551264-26117-1-git-send-email-zhangqiumiao1@huwei.com>

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

           reply	other threads:[~2020-12-21 12:12 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1608551264-26117-1-git-send-email-zhangqiumiao1@huwei.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X+CRTqDQwVYSZQBi@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhangqiumiao1@huawei.com \
    --cc=zhangqiumiao1@huwei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.