linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Javier Martinez Canillas <javierm@redhat.com>,
	linux-kernel@vger.kernel.org
Cc: linux-fbdev@vger.kernel.org, Helge Deller <deller@gmx.de>,
	Zheyu Ma <zheyuma97@gmail.com>,
	Changcheng Deng <deng.changcheng@zte.com.cn>,
	dri-devel@lists.freedesktop.org,
	Maxime Ripard <maxime@cerno.tech>,
	Zhen Lei <thunder.leizhen@huawei.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH 2/2] fbdev: Make fb_release() return -ENODEV if fbdev was unregistered
Date: Mon, 2 May 2022 15:20:23 +0200	[thread overview]
Message-ID: <193c9eef-af13-219c-e5e0-2cc9469bf562@suse.de> (raw)
In-Reply-To: <20220502130944.363776-3-javierm@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 1934 bytes --]



Am 02.05.22 um 15:09 schrieb Javier Martinez Canillas:
> A reference to the framebuffer device struct fb_info is stored in the file
> private data, but this reference could no longer be valid and must not be
> accessed directly. Instead, the file_fb_info() accessor function must be
> used since it does sanity checking to make sure that the fb_info is valid.
> 
> This can happen for example if the fbdev driver was one that is using a
> framebuffer provided by the system firmware. In that case, the fbdev core
> could unregister the framebuffer device if a real video driver is probed.
> 
> Reported-by: Maxime Ripard <maxime@cerno.tech>
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

This seems like the correct thing to do in any case. Thanks for the 
patch. Before merging, you should also add

Fixes: 27599aacbaef ("fbdev: Hot-unplug firmware fb devices on forced 
removal")
Reported-by: Junxiao Chang <junxiao.chang@intel.com>

Best regards
Thomas

> ---
> 
>   drivers/video/fbdev/core/fbmem.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index 20d8929df79f..d68097105f93 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -1439,7 +1439,10 @@ fb_release(struct inode *inode, struct file *file)
>   __acquires(&info->lock)
>   __releases(&info->lock)
>   {
> -	struct fb_info * const info = file->private_data;
> +	struct fb_info * const info = file_fb_info(file);
> +
> +	if (!info)
> +		return -ENODEV;
>   
>   	lock_fb_info(info);
>   	if (info->fbops->fb_release)

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2022-05-02 13:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 13:09 [PATCH 0/2] fbdev: Fix a NULL pointer dereference in fb_release() Javier Martinez Canillas
2022-05-02 13:09 ` [PATCH 1/2] fbdev: Check in file_fb_info() if the fb_info was already been freed Javier Martinez Canillas
2022-05-02 13:26   ` Thomas Zimmermann
2022-05-02 13:36     ` Javier Martinez Canillas
2022-05-02 13:09 ` [PATCH 2/2] fbdev: Make fb_release() return -ENODEV if fbdev was unregistered Javier Martinez Canillas
2022-05-02 13:20   ` Thomas Zimmermann [this message]
2022-05-02 13:39     ` Javier Martinez Canillas
2022-05-04  9:47   ` Daniel Vetter
2022-05-04 10:09     ` Javier Martinez Canillas
2022-05-04 10:15       ` Daniel Vetter

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=193c9eef-af13-219c-e5e0-2cc9469bf562@suse.de \
    --to=tzimmermann@suse.de \
    --cc=alexander.deucher@amd.com \
    --cc=deller@gmx.de \
    --cc=deng.changcheng@zte.com.cn \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=maxime@cerno.tech \
    --cc=sam@ravnborg.org \
    --cc=thunder.leizhen@huawei.com \
    --cc=zheyuma97@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;
as well as URLs for NNTP newsgroup(s).