public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Nicolas Pitre <nico@fluxnic.net>
Cc: gregkh@linuxfoundation.org, jslaby@suse.com,
	daniel.vetter@ffwll.ch, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vt: fix unicode console freeing with a common interface
Date: Sat, 2 May 2020 17:57:29 +0200	[thread overview]
Message-ID: <20200502155729.GA12824@ravnborg.org> (raw)
In-Reply-To: <nycvar.YSQ.7.76.2005021043110.2671@knanqh.ubzr>

Hi Nicolas

On Sat, May 02, 2020 at 11:01:07AM -0400, Nicolas Pitre wrote:
> By directly using kfree() in different places we risk missing one if
> it is switched to using vfree(), especially if the corresponding
> vmalloc() is hidden away within a common abstraction.
> 
> Oh wait, that's exactly what happened here.
> 
> So let's fix this by creating a common abstraction for the free case
> as well.
> 
> Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
> Reported-by: syzbot+0bfda3ade1ee9288a1be@syzkaller.appspotmail.com
> Fixes: 9a98e7a80f95 ("vt: don't use kmalloc() for the unicode screen buffer")
> Cc: <stable@vger.kernel.org>

Looks good.
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

Not the I know the code, but verified that no more kfree() was
used for vc_uni_screen.

	Sam

> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index e5ffed795e..48a8199f78 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -365,9 +365,14 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
>  	return uniscr;
>  }
>  
> +static void vc_uniscr_free(struct uni_screen *uniscr)
> +{
> +	vfree(uniscr);
> +}
> +
>  static void vc_uniscr_set(struct vc_data *vc, struct uni_screen *new_uniscr)
>  {
> -	vfree(vc->vc_uni_screen);
> +	vc_uniscr_free(vc->vc_uni_screen);
>  	vc->vc_uni_screen = new_uniscr;
>  }
>  
> @@ -1230,7 +1235,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
>  	err = resize_screen(vc, new_cols, new_rows, user);
>  	if (err) {
>  		kfree(newscreen);
> -		kfree(new_uniscr);
> +		vc_uniscr_free(new_uniscr);
>  		return err;
>  	}
>  

      reply	other threads:[~2020-05-02 15:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-02 15:01 [PATCH] vt: fix unicode console freeing with a common interface Nicolas Pitre
2020-05-02 15:57 ` Sam Ravnborg [this message]

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=20200502155729.GA12824@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nico@fluxnic.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox