Re: [PATCH 2/3] s390/pci: Rework__zpci_event_availability() to remove conditional locking

Heiko Carstens <[email protected]> Mon, 3 Aug 2026 13:29:57 +0200
Newsgroups dev.linux.lists.sashiko-reviews,org.kernel.vger.linux-s390
Message-ID <[email protected]>
On Mon, Aug 03, 2026 at 10:17:59AM +0000, [email protected] wrote:
> 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.
> > -	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?

This is correct, but trying to fix this I also looked a bit deeper
into the code and found a "pre-existing" issue. Oh, well..