Page MenuHomeFreeBSD

LinuxKPI: pci: cleanup the error path in linux_pci_attach_device()
Needs ReviewPublic

Authored by bz on Jun 4 2026, 9:36 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jul 28, 8:23 AM
Unknown Object (File)
Sun, Jul 26, 6:16 PM
Unknown Object (File)
Sat, Jul 25, 7:47 PM
Unknown Object (File)
Tue, Jul 21, 7:04 AM
Unknown Object (File)
Tue, Jul 21, 5:05 AM
Unknown Object (File)
Sun, Jul 19, 4:14 AM
Unknown Object (File)
Thu, Jul 16, 10:36 PM
Unknown Object (File)
Wed, Jul 8, 5:25 AM
Subscribers

Details

Reviewers
None
Group Reviewers
linuxkpi
Summary

Very much like the cleanup done for the detach call, try to address a
comment left behind and cleanup all the resources allocated in case
of error during attach. This is slightly less complex than
lkpi_pci_dev_release() as some of the lists cannot yet hold allocated
resources so we can skip this.

While this mostly a copy of lkpi_pci_dev_release(), we could possibly
call pci_put_dev() in any case and be done and let the (*release)
function do its job. However there are some uncertainties still
(see other comments) which would prevent us doing so. Punt for the
moment and leave a comment and revisit once more work on the cleanup
paths has finished.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Tested by: Mark Millard (marklmi yahoo.com)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 74087
Build 70970: arc lint + arc unit

Event Timeline

bz requested review of this revision.Jun 4 2026, 9:36 AM
sys/compat/linuxkpi/common/src/linux_pci.c
650–669

I'm not sure what style(9) has to say, but this unindented comment gave me the impression that a new function started here.

sys/compat/linuxkpi/common/src/linux_pci.c
650–669

That was certainly no planned. I'll do the 8>>

Properly indent comment and put it under the first label.

bz marked an inline comment as done.Jun 21 2026, 9:11 PM

We have a bug report for this problem now (this review seems to solve it).
Here's the end of the thread on current: https://lists.freebsd.org/archives/freebsd-current/2026-July/010533.html

Would be really good to get review on this to get more problems out.

Looks reasonable to me

sys/compat/linuxkpi/common/src/linux_pci.c
657–659

can we give a hint as to what the other parts are? Do we know this doesn't work, or just needs more investigation/vetting?

sys/compat/linuxkpi/common/src/linux_pci.c
657–659

I believe when I have done all the changes incrementally I did not want to further mix them up.
I also believe I wasn't entirely sure that we do not have any edge cases (NULL pointers or others) we would trip over (any side effects).

I think after D57431 gets also sorted I can revisit this as then line 665 will indeed change to what the comment already hints at.