The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Hao Peng <penghaob@uniontech.com>
Cc: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com,
	hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm:vkms: Add NULL value after free function In function vkms_exit, after kfree(default_config), give specific NULL value to pointer default_config to avoid wild pointer.
Date: Mon, 17 May 2021 16:09:45 +0200	[thread overview]
Message-ID: <YKJ5KU4ZOXvUPM8o@phenom.ffwll.local> (raw)
In-Reply-To: <20210512115554.10431-1-penghaob@uniontech.com>

On Wed, May 12, 2021 at 07:55:54PM +0800, Hao Peng wrote:
> Signed-off-by: Hao Peng <penghaob@uniontech.com>
> ---
>  drivers/gpu/drm/vkms/vkms_drv.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
> index 2173b82606f6..6c63201db5d0 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.c
> +++ b/drivers/gpu/drm/vkms/vkms_drv.c
> @@ -227,6 +227,7 @@ static void __exit vkms_exit(void)
>  		vkms_destroy(default_config);
>  
>  	kfree(default_config);
> +	default_config = NULL;

This is the last thing before the module us unloaded, which means no one
can access default_config anymore. So also no point in clearing it.
-Daniel

>  }
>  
>  module_init(vkms_init);
> -- 
> 2.20.1
> 
> 
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

      reply	other threads:[~2021-05-17 14:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 11:55 [PATCH] drm:vkms: Add NULL value after free function In function vkms_exit, after kfree(default_config), give specific NULL value to pointer default_config to avoid wild pointer Hao Peng
2021-05-17 14:09 ` Daniel Vetter [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=YKJ5KU4ZOXvUPM8o@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=melissa.srw@gmail.com \
    --cc=penghaob@uniontech.com \
    --cc=rodrigosiqueiramelo@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox