From: Helge Deller <deller@gmx.de>
To: Andrey Misiurov <andrey.misyrov@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Abdun Nihaal <nihaal@cse.iitm.ac.in>,
stable@vger.kernel.org
Subject: Re: [PATCH] fbdev: core: Initialize modelist in framebuffer_alloc()
Date: Mon, 12 Oct 2026 23:19:24 +0200 [thread overview]
Message-ID: <99014db6-89e9-495d-acec-e53134ce2a90@gmx.de> (raw)
In-Reply-To: <20261012175338.2283897-1-andrey.misyrov@gmail.com>
On 10/12/26 19:53, Andrey Misiurov wrote:
> framebuffer_alloc() returns zeroed memory, so info->modelist starts out
> with NULL next and prev pointers. The list head is initialized only
> later, by fb_videomode_to_modelist() or by do_register_framebuffer().
>
> The "fix potential memory leak" commits listed below added
> fb_destroy_modelist(&info->modelist) to the probe error paths of s3fb,
> tdfxfb, tridentfb, i740fb and carminefb. These paths can run before
> the list head is initialized:
>
> - s3fb, tdfxfb, tridentfb and i740fb call fb_videomode_to_modelist()
> only after a successful EDID read, and tridentfb can also hit the
> error path on an ioremap() or kmalloc() failure before that;
> - carminefb jumps to the error path when fb_find_mode() fails, before
> its fb_videomode_to_modelist() call.
>
> fb_destroy_modelist() then dereferences the NULL head. Reproduced on
> Debian 12 (6.1.180) by binding s3fb to a VGA device without EDID and
> forcing fb_alloc_cmap() to fail:
>
> s3fb 0000:00:03.0: cannot allocate colormap
> BUG: kernel NULL pointer dereference, address: 0000000000000000
> RIP: 0010:fb_destroy_modelist+0x10/0x80
> Call Trace:
> s3_pci_probe.cold+0x12b/0x2bf [s3fb]
> local_pci_probe+0x41/0x80
> pci_device_probe+0xc3/0x240
> really_probe+0xde/0x380
> __driver_probe_device+0x84/0x150
> driver_probe_device+0x1f/0x90
> __driver_attach+0xce/0x1c0
> bus_for_each_dev+0x87/0xd0
> bus_add_driver+0x1ae/0x200
> driver_register+0x89/0xe0
> do_one_initcall+0x59/0x220
> do_init_module+0x4a/0x1f0
>
> Initialize the list head in framebuffer_alloc(), so info->modelist is
> always a valid, possibly empty, list and fb_destroy_modelist() is safe
> on every error path. Keep the lazy initialization in
> do_register_framebuffer(), as drivers that embed struct fb_info rather
> than calling framebuffer_alloc() still depend on it.
>
> Fixes: 3b0ed04bc852 ("fbdev: s3fb: fix potential memory leak in s3_pci_probe()")
> Fixes: bb019d755366 ("fbdev: tdfxfb: fix potential memory leak in tdfxfb_probe()")
> Fixes: 7a35ec619d9a ("fbdev: tridentfb: fix potential memory leak in trident_pci_probe()")
> Fixes: 5936063409af ("fbdev: i740fb: fix potential memory leak in i740fb_probe()")
> Fixes: 6fcca16a2b19 ("fbdev: carminefb: fix potential memory leak in alloc_carmine_fb()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Andrey Misiurov <andrey.misyrov@gmail.com>
> ---
> drivers/video/fbdev/core/fb_info.c | 1 +
> 1 file changed, 1 insertion(+)
applied.
Thanks!
Helge
prev parent reply other threads:[~2026-10-12 21:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 17:53 [PATCH] fbdev: core: Initialize modelist in framebuffer_alloc() Andrey Misiurov
2026-10-12 21:19 ` 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=99014db6-89e9-495d-acec-e53134ce2a90@gmx.de \
--to=deller@gmx.de \
--cc=andrey.misyrov@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nihaal@cse.iitm.ac.in \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
/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