All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Myeonghun Pak" <mhun512@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] fbdev: tdfxfb: fix PCI enable cleanup with pcim_enable_device()
Date: Wed, 01 Jul 2026 11:31:52 +0000	[thread overview]
Message-ID: <20260701113153.AC9701F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701112147.55048-1-mhun512@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Calling `fb_destroy_modelist()` on a zero-initialized list head causes a kernel NULL pointer dereference during probe error cleanup.
--

commit e7b75661a1b19e182f38b86092ac7adc397e31df
Author: Myeonghun Pak <mhun512@gmail.com>

fbdev: tdfxfb: fix PCI enable cleanup with pcim_enable_device()

tdfxfb_probe() enables the PCI device with pci_enable_device(), but
several failure paths after that point return without disabling it.
This patch uses pcim_enable_device() so the PCI device is disabled
automatically on probe failure and driver detach.

> diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c
> index cc6a074f3165b..9a06cef756994 100644
> --- a/drivers/video/fbdev/tdfxfb.c
> +++ b/drivers/video/fbdev/tdfxfb.c
> @@ -1385,7 +1385,7 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	if (err)
>  		return err;
>  
> -	err = pci_enable_device(pdev);
> +	err = pcim_enable_device(pdev);
>  	if (err) {
>  		printk(KERN_ERR "tdfxfb: Can't enable pdev: %d\n", err);
>  		return err;

[Severity: High]
This is a pre-existing issue, but does the out_err_iobase error path cause a 
NULL pointer dereference during device probe?

If CONFIG_FB_3DFX_I2C is enabled but the monitor's EDID does not provide a
mode database (specs->modedb == NULL), fb_videomode_to_modelist() is skipped.
This leaves the info->modelist list head zero-initialized (with next and prev
pointers set to NULL) as originally allocated by framebuffer_alloc().

If a subsequent operation fails (e.g., info->var.yres_virtual < info->var.yres
or fb_alloc_cmap() returning -ENOMEM), the driver jumps to out_err_iobase:

drivers/video/fbdev/tdfxfb.c:tdfxfb_probe() {
    ...
out_err_iobase:
#ifdef CONFIG_FB_3DFX_I2C
    fb_destroy_modelist(&info->modelist);
...
}

This unconditionally calls fb_destroy_modelist(), which uses
list_for_each_safe():

drivers/video/fbdev/core/modedb.c:fb_destroy_modelist() {
    struct list_head *pos, *n;

    list_for_each_safe(pos, n, head) {
    ...
}

Because head->next is NULL, pos evaluates to NULL when the macro evaluates
n = pos->next, resulting in an immediate NULL pointer dereference.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260701112147.55048-1-mhun512@gmail.com?part=1

      reply	other threads:[~2026-07-01 11:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 11:21 [PATCH] fbdev: tdfxfb: fix PCI enable cleanup with pcim_enable_device() Myeonghun Pak
2026-07-01 11:31 ` sashiko-bot [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=20260701113153.AC9701F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mhun512@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.