All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wentao Liang" <vulab@iscas.ac.cn>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: keystone: drop host bridge reference in ks_pcie_quirk()
Date: Thu, 05 Nov 2026 15:45:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-199339@kernel.org> (raw)
In-Reply-To: <20261103104239.1373754-1-vulab@iscas.ac.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] PCI: keystone: unexported pci_put_host_bridge_device() breaks module build
--

commit 7a2a6fc28bf725e307c0f83095897f6ac6b29cc8
Author: Wentao Liang <vulab@iscas.ac.cn>

PCI: keystone: drop host bridge reference in ks_pcie_quirk()

This commit fixes a host bridge device reference leak in ks_pcie_quirk() by
calling pci_put_host_bridge_device() via a cleanup label on all exit paths
after pci_get_host_bridge_device().

> diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
> index edfbc32904cda..0c46887de0d5d 100644
> --- a/drivers/pci/controller/dwc/pci-keystone.c
> +++ b/drivers/pci/controller/dwc/pci-keystone.c
> @@ -579,26 +579,33 @@ static void ks_pcie_quirk(struct pci_dev *dev)
>  	 * when MRRS is set to more than 128 bytes. Force the MRRS to
>  	 * 128 bytes in all downstream devices.
>  	 */
> -	if (pci_match_id(am6_pci_devids, bridge)) {
> -		bridge_dev = pci_get_host_bridge_device(dev);
> -		if (!bridge_dev || !bridge_dev->parent)
> -			return;
> -
> -		ks_pcie = dev_get_drvdata(bridge_dev->parent);
> -		if (!ks_pcie)
> -			return;
> -
> -		val = ks_pcie_app_readl(ks_pcie, PID);
> -		val &= RTL;
> -		val >>= RTL_SHIFT;
> -		if (val != AM6_PCI_PG1_RTL_VER)
> -			return;
> -
> -		if (pcie_get_readrq(dev) > 128) {
> -			dev_info(&dev->dev, "limiting MRRS to 128 bytes\n");
> -			pcie_set_readrq(dev, 128);
> -		}
> +	if (!pci_match_id(am6_pci_devids, bridge))
> +		return;
> +
> +	bridge_dev = pci_get_host_bridge_device(dev);
> +	if (!bridge_dev)
> +		return;
> +
> +	if (!bridge_dev->parent)
> +		goto put_bridge;
> +
> +	ks_pcie = dev_get_drvdata(bridge_dev->parent);
> +	if (!ks_pcie)
> +		goto put_bridge;
> +
> +	val = ks_pcie_app_readl(ks_pcie, PID);
> +	val &= RTL;
> +	val >>= RTL_SHIFT;
> +	if (val != AM6_PCI_PG1_RTL_VER)
> +		goto put_bridge;
> +
> +	if (pcie_get_readrq(dev) > 128) {
> +		dev_info(&dev->dev, "limiting MRRS to 128 bytes\n");
> +		pcie_set_readrq(dev, 128);
>  	}
> +
> +put_bridge:
> +	pci_put_host_bridge_device(bridge_dev);
>  }

[Severity: Low]
Will calling pci_put_host_bridge_device() here break the module build when
CONFIG_PCI_KEYSTONE_HOST=m or CONFIG_PCI_KEYSTONE_EP=m on non-ARM32 targets
(which selects CONFIG_PCI_KEYSTONE_TRISTATE=m)?

In drivers/pci/host-bridge.c, pci_get_host_bridge_device() is exported for
modules, but pci_put_host_bridge_device() is not:

drivers/pci/host-bridge.c:
    struct device *pci_get_host_bridge_device(struct pci_dev *dev)
    {
        ...
    }
    EXPORT_SYMBOL_GPL(pci_get_host_bridge_device);

    void  pci_put_host_bridge_device(struct device *dev)
    {
        kobject_put(&dev->kobj);
    }

Additionally, pci_put_host_bridge_device() is currently only declared in the
internal header drivers/pci/pci.h rather than include/linux/pci.h alongside
pci_get_host_bridge_device().

Should pci_put_host_bridge_device() be exported with EXPORT_SYMBOL_GPL() in
drivers/pci/host-bridge.c (and moved to include/linux/pci.h) so modular builds
of pci-keystone.ko do not fail at modpost?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103104239.1373754-1-vulab@iscas.ac.cn?part=1

      parent reply	other threads:[~2026-11-05 15:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 10:42 [PATCH] PCI: keystone: drop host bridge reference in ks_pcie_quirk() Wentao Liang
2026-11-03 11:10 ` Krzysztof Kozlowski
2026-11-03 23:33 ` kernel test robot
2026-11-05 15:45 ` 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=sashiko-outbox-199339@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vulab@iscas.ac.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 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.