From: Myeonghun Pak <mhun512@gmail.com>
To: David Airlie <airlied@redhat.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Myeonghun Pak <mhun512@gmail.com>, Ijae Kim <ae878000@gmail.com>
Subject: [PATCH] agp: efficeon: Disable PCI device on probe failure
Date: Tue, 23 Jun 2026 16:52:46 +0900 [thread overview]
Message-ID: <20260623075300.42474-1-mhun512@gmail.com> (raw)
agp_efficeon_probe() enables the PCI device before checking whether the
GART resource can be assigned and before registering the AGP bridge. If
either of those later steps fails, the probe path can return without
dropping the enable reference.
Route the resource-assignment failure through a shared unwind path that
puts the bridge before disabling the PCI device. Also check the return
value from agp_add_bridge() explicitly, disabling the PCI device on
failure while leaving the bridge cleanup to agp_add_bridge()'s failure
handling.
Balance the successful probe path by disabling the PCI device from remove()
after the AGP bridge has been removed and released.
This issue was identified during our ongoing static-analysis research while
reviewing kernel code.
Fixes: 46cfc58a77de ("agp: efficeon-agp: do not use PCI resources before pci_enable_device()")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
drivers/char/agp/efficeon-agp.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index 0d25bbdc7e..03804b08ef 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -346,6 +346,7 @@ static int agp_efficeon_probe(struct pci_dev *pdev,
struct agp_bridge_data *bridge;
u8 cap_ptr;
struct resource *r;
+ int err;
cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
if (!cap_ptr)
@@ -388,8 +389,8 @@ static int agp_efficeon_probe(struct pci_dev *pdev,
if (!r->start && r->end) {
if (pci_assign_resource(pdev, 0)) {
printk(KERN_ERR PFX "could not assign resource 0\n");
- agp_put_bridge(bridge);
- return -ENODEV;
+ err = -ENODEV;
+ goto err_put_bridge;
}
}
@@ -401,7 +402,17 @@ static int agp_efficeon_probe(struct pci_dev *pdev,
}
pci_set_drvdata(pdev, bridge);
- return agp_add_bridge(bridge);
+ err = agp_add_bridge(bridge);
+ if (err)
+ goto err_disable_device;
+
+ return 0;
+
+err_put_bridge:
+ agp_put_bridge(bridge);
+err_disable_device:
+ pci_disable_device(pdev);
+ return err;
}
static void agp_efficeon_remove(struct pci_dev *pdev)
@@ -410,6 +421,7 @@ static void agp_efficeon_remove(struct pci_dev *pdev)
agp_remove_bridge(bridge);
agp_put_bridge(bridge);
+ pci_disable_device(pdev);
}
static int agp_efficeon_resume(struct device *dev)
--
2.47.1
next reply other threads:[~2026-06-23 7:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 7:52 Myeonghun Pak [this message]
2026-06-23 8:03 ` [PATCH] agp: efficeon: Disable PCI device on probe failure sashiko-bot
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=20260623075300.42474-1-mhun512@gmail.com \
--to=mhun512@gmail.com \
--cc=ae878000@gmail.com \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@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 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.