From: sashiko-bot@kernel.org
To: "Manivannan Sadhasivam via B4 Relay"
<devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v3 4/9] power: sequencing: pcie-m2: Create serdev for PCI devices present before probe
Date: Tue, 19 May 2026 10:04:52 +0000 [thread overview]
Message-ID: <20260519100452.96967C2BCC6@smtp.kernel.org> (raw)
In-Reply-To: <20260519-pwrseq-m2-bt-v3-4-b39dc2ae3966@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Leaked serdev_controller reference on early exit in pwrseq_pcie_m2_create_serdev_one()
- [High] Mixing goto-based error handling with scope-based cleanups (__free and scoped_guard) in the same function
--
commit f9e3f8cd7dae54d53f6be50d3fa50b1da0d87fe2
Author: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
power: sequencing: pcie-m2: Create serdev for PCI devices present before probe
This commit adds support for creating serdevs for PCI devices that are
already present before the driver completes its probe phase. It complements
the existing notifier-based hotplug support to handle existing devices.
> diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequencing/pwrseq-pcie-m2.c
> index 038271207a27e..8164c44289775 100644
> --- a/drivers/power/sequencing/pwrseq-pcie-m2.c
> +++ b/drivers/power/sequencing/pwrseq-pcie-m2.c
[ ... ]
> @@ -259,6 +259,14 @@ static int pwrseq_pcie_m2_create_serdev(struct pwrseq_pcie_m2_ctx *ctx,
> return 0;
> }
>
> + /* Bail out if the serdev device was already created for the PCI dev */
> + scoped_guard(mutex, &ctx->list_lock) {
> + list_for_each_entry(pci_dev, &ctx->pci_devices, list) {
> + if (pci_dev->pdev == pdev)
> + return 0;
> + }
> + }
> +
Earlier in this function, of_find_serdev_controller_by_node() acquires a
reference to the serdev controller. If the device is found in the list,
the code returns 0 directly from within the scoped_guard block.
Does this early return leak the serdev controller reference by bypassing
the required serdev_controller_put() call at the end of the function?
Additionally, include/linux/cleanup.h notes that mixing goto and cleanup
helpers like guard() in the same function is not expected. This function
still relies on multiple goto labels (e.g., err_put_ctrl, err_free_pci_dev)
for error handling. Could this function be converted fully to scope-based
cleanups to avoid potential LIFO ordering issues?
[ ... ]
> @@ -408,18 +416,56 @@ static int pwrseq_pcie_m2_register_notifier(struct pwrseq_pcie_m2_ctx *ctx, stru
[ ... ]
> +static int pwrseq_pcie_m2_create_serdev(struct pwrseq_pcie_m2_ctx *ctx)
> +{
> + struct pci_dev *pdev = NULL;
> + int ret;
> +
> + if (!pwrseq_pcie_m2_check_remote_node(ctx->dev, 3, 0, "serial") ||
> + !pwrseq_pcie_m2_check_remote_node(ctx->dev, 0, 0, "pcie"))
> + return 0;
> +
> + struct device_node *pci_parent __free(device_node) =
> + of_graph_get_remote_node(dev_of_node(ctx->dev), 0, 0);
> + if (!pci_parent)
> + return 0;
> +
> + /* Create serdev for existing PCI devices if required */
> + for_each_pci_dev(pdev) {
> + if (!pdev->dev.parent || pci_parent != pdev->dev.parent->of_node)
> + continue;
> +
> + if (!pci_match_id(pwrseq_m2_pci_ids, pdev))
> + continue;
> +
> + ret = pwrseq_pcie_m2_create_serdev_one(ctx, pdev);
> + if (ret) {
> + dev_err_probe(ctx->dev, ret,
> + "Failed to create serdev for PCI device (%s)\n",
> + pci_name(pdev));
> + pci_dev_put(pdev);
> + goto err_remove_serdev;
> + }
> }
>
> return 0;
> +
> +err_remove_serdev:
> + pwrseq_pcie_m2_remove_serdev(ctx, NULL);
> +
> + return ret;
> }
Similar to the concern above, this newly introduced function declares
pci_parent using __free(device_node) but also uses goto-based error
handling with the err_remove_serdev label.
Does this mix of goto and __free() violate the subsystem guidelines
recommending against combining both cleanup styles in the same function?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260519-pwrseq-m2-bt-v3-0-b39dc2ae3966@oss.qualcomm.com?part=4
next prev parent reply other threads:[~2026-05-19 10:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 8:55 [PATCH v3 0/9] Fixes/improvements for the PCI M.2 power sequencing driver Manivannan Sadhasivam
2026-05-19 8:55 ` Manivannan Sadhasivam via B4 Relay
2026-05-19 8:55 ` [PATCH v3 1/9] power: sequencing: pcie-m2: Fix inconsistent function prefixes Manivannan Sadhasivam
2026-05-19 8:55 ` Manivannan Sadhasivam via B4 Relay
2026-05-19 13:16 ` Fixes/improvements for the PCI M.2 power sequencing driver bluez.test.bot
2026-05-19 8:55 ` [PATCH v3 2/9] power: sequencing: pcie-m2: Allow creating serdev for multiple PCI devices Manivannan Sadhasivam
2026-05-19 8:55 ` Manivannan Sadhasivam via B4 Relay
2026-05-19 9:40 ` sashiko-bot
2026-05-19 8:55 ` [PATCH v3 3/9] power: sequencing: pcie-m2: Improve PCI device ID check Manivannan Sadhasivam
2026-05-19 8:55 ` Manivannan Sadhasivam via B4 Relay
2026-05-19 8:55 ` [PATCH v3 4/9] power: sequencing: pcie-m2: Create serdev for PCI devices present before probe Manivannan Sadhasivam
2026-05-19 8:55 ` Manivannan Sadhasivam via B4 Relay
2026-05-19 10:04 ` sashiko-bot [this message]
2026-05-19 8:56 ` [PATCH v3 5/9] power: sequencing: pcie-m2: Create BT node based on the pci_device_id[] table Manivannan Sadhasivam
2026-05-19 8:56 ` Manivannan Sadhasivam via B4 Relay
2026-05-19 8:56 ` [PATCH v3 6/9] power: sequencing: Add an API to return the pwrseq device's 'dev' pointer Manivannan Sadhasivam
2026-05-19 8:56 ` Manivannan Sadhasivam via B4 Relay
2026-05-19 10:45 ` sashiko-bot
2026-05-19 8:56 ` [PATCH v3 7/9] Bluetooth: hci_qca: Add M.2 Bluetooth device support using pwrseq Manivannan Sadhasivam
2026-05-19 8:56 ` Manivannan Sadhasivam via B4 Relay
2026-05-19 11:30 ` sashiko-bot
2026-05-19 8:56 ` [PATCH v3 8/9] Bluetooth: hci_qca: Rename 'power_ctrl_enabled' to 'bt_en_available' Manivannan Sadhasivam
2026-05-19 8:56 ` Manivannan Sadhasivam via B4 Relay
2026-05-19 8:56 ` [PATCH v3 9/9] Bluetooth: hci_qca: Set 'bt_en_available' based on W_DISABLE2# presence in M.2 connector Manivannan Sadhasivam
2026-05-19 8:56 ` Manivannan Sadhasivam via B4 Relay
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=20260519100452.96967C2BCC6@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org \
--cc=linux-pci@vger.kernel.org \
--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.