Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH 2/3] s390/pci: Rework__zpci_event_availability() to remove conditional locking
Date: Mon, 03 Aug 2026 10:17:59 +0000	[thread overview]
Message-ID: <20260803101800.552771F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260803100723.2343688-3-hca@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The `zdev` reference obtained via `get_zdev_by_fid()` is leaked when handling the `0x0306` PCI event.
--

--- Patch [2]: [PATCH 2/3] s390/pci: Rework__zpci_event_availability() to remove conditional locking ---
commit abeb29e9ac48aa95001741be64e50a68bcadf6fd
Author: Heiko Carstens <hca@linux.ibm.com>

s390/pci: Rework__zpci_event_availability() to remove conditional locking

This commit refactors the __zpci_event_availability() function to avoid
taking the device state lock conditionally. The restructuring handles
different PCI event codes explicitly to resolve static analysis warnings.

> diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c
> index 48fa26dcbee14..37acee2c7d257 100644
> --- a/arch/s390/pci/pci_event.c
> +++ b/arch/s390/pci/pci_event.c
> @@ -390,18 +390,21 @@ static void zpci_event_reappear(struct zpci_dev *zdev)
>  static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
>  {
>  	struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
> -	bool existing_zdev = !!zdev;
>  	enum zpci_state state;
>  
>  	zpci_dbg(3, "avl fid:%x, fh:%x, pec:%x\n",
>  		 ccdf->fid, ccdf->fh, ccdf->pec);
>  
> -	if (existing_zdev)
> -		mutex_lock(&zdev->state_lock);
> +	if (ccdf->pec == 0x0306) {
> +		/* 0x308 or 0x302 for multiple devices */
> +		zpci_remove_reserved_devices();
> +		zpci_scan_devices();
> +		return;

[Severity: High]
Does this early return leak the zdev reference?

If get_zdev_by_fid() finds an existing device, it increments its reference
count. By returning directly here when the event code is 0x0306, it seems we
skip calling zpci_zdev_put() at the end of the function. Could this prevent
the device from being properly freed during hot-unplug over time?

> +	}
>  
> -	switch (ccdf->pec) {
> -	case 0x0301: /* Reserved|Standby -> Configured */
> -		if (!zdev) {

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260803100723.2343688-1-hca@linux.ibm.com?part=2

  reply	other threads:[~2026-08-03 10:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 10:07 [PATCH 0/3] s390/pci: Enable CONTEXT_ANALYSIS Heiko Carstens
2026-08-03 10:07 ` [PATCH 1/3] s390/pci: Rework __zpci_event_error() to remove conditional locking Heiko Carstens
2026-08-03 10:12   ` sashiko-bot
2026-08-03 10:07 ` [PATCH 2/3] s390/pci: Rework__zpci_event_availability() " Heiko Carstens
2026-08-03 10:17   ` sashiko-bot [this message]
2026-08-03 11:29     ` Heiko Carstens
2026-08-03 10:07 ` [PATCH 3/3] s390/pci: Enable CONTEXT_ANALYSIS Heiko Carstens
2026-08-03 10:13   ` 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=20260803101800.552771F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox