From: Helge Deller <deller@gmx.de>
To: YuanZhe Liu <25031212351@stu.xidian.edu.cn>,
Steve Glendinning <steve.glendinning@shawell.net>
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, Bin Yu <byu@xidian.edu.cn>,
Cheng Wen <wencheng@xidian.edu.cn>
Subject: Re: [PATCH] fbdev: smscufx: don't free registered framebuffer on probe error
Date: Wed, 18 Nov 2026 20:15:28 +0100 [thread overview]
Message-ID: <4a5d5e4b-e376-463e-a919-2c16a625be1d@gmx.de> (raw)
In-Reply-To: <20261102084830.9890-1-25031212351@stu.xidian.edu.cn>
On 11/2/26 09:48, YuanZhe Liu wrote:
> register_framebuffer() can return an error after the framebuffer has
> already been installed: do_register_framebuffer() bumps info->count,
> creates /dev/fbN and stores the fb_info in registered_fb[] before it
> returns the result of the console takeover, and that takeover may fail.
> ufx_usb_probe() treats any error as "nothing was registered" and unwinds
> through reset_active, which releases the fb_info and drops both
> references to struct ufx_data, freeing @dev.
>
> The framebuffer stays registered and can still be opened, so the next
> open() of /dev/fbN reaches ufx_ops_open() with info->par pointing at
> freed memory:
>
> refcount_t: addition on 0; use-after-free.
> WARNING: lib/refcount.c:25 at refcount_warn_saturate
> Call Trace:
> kref_get
> ufx_ops_open drivers/video/fbdev/smscufx.c:1033
> fb_open drivers/video/fbdev/core/fb_chrdev.c:351
> chrdev_open
> ...
> refcount_t: underflow; use-after-free.
> WARNING: lib/refcount.c:28 at refcount_warn_saturate
> Call Trace:
> ufx_ops_release drivers/video/fbdev/smscufx.c:1135
> fb_release drivers/video/fbdev/core/fb_chrdev.c:378
> __fput
>
> Reuse the "has this fb_info been registered" test that ufx_setup_modes()
> already uses: take the error path only when refcount_read(&info->count)
> says the core did not register the framebuffer. A failed console
> takeover is not fatal for the driver, so report it and keep the
> framebuffer registered; the disconnect callback will unregister it
> normally.
>
> Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters")
> Cc: stable@vger.kernel.org
> ---
> drivers/video/fbdev/smscufx.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
applied.
Thanks!
Helge
prev parent reply other threads:[~2026-11-18 19:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 8:48 YuanZhe Liu
2026-11-18 19:15 ` Helge Deller [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=4a5d5e4b-e376-463e-a919-2c16a625be1d@gmx.de \
--to=deller@gmx.de \
--cc=25031212351@stu.xidian.edu.cn \
--cc=byu@xidian.edu.cn \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=steve.glendinning@shawell.net \
--cc=wencheng@xidian.edu.cn \
/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
all inboxes | Powered by JetHome®