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.
Referenced Files
Unknown Object (File)
Mon, Aug 17, 7:18 AM
Unknown Object (File)
Sat, Aug 15, 10:07 AM
Unknown Object (File)
Sun, Aug 9, 3:30 AM
Unknown Object (File)
Sun, Aug 9, 2:34 AM
Unknown Object (File)
Sun, Aug 9, 2:17 AM
Unknown Object (File)
Sat, Aug 8, 11:21 PM
Unknown Object (File)
Sat, Aug 8, 5:16 PM
Unknown Object (File)
Sat, Aug 8, 9:31 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.

@emaste if I update the review for the missing call, do you think we could get this in for now? I can remove the comment as well if that's better. But I'd rather have this in and a bug fixed than drive it to perfection just yet (especially given the other open items in the stack).

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

This needs a lkpi_devres_release_free_list(&pdev->dev); here too.