LinuxKPI: pci: fix two errors in lkpi_pci_get_device()
On any result we need to acquire a reference. pci_dev_get() deals with
a NULL argument so we can simply pass what we "found" at the end.
This will avoid reference count problems.
If the iteration on the linux list in lkpi_pci_get_device() does
not find a match pdev will still be defined at the end of the
loop but not pointing to a valid pdev.
Store the found entry in a 2nd variable which otherwise will be NULL.
This will avoid random panics, usually in sysfs_remove_dir() when
the reference gets released.
Found during mt76 bringup.
Sponsored by: The FreeBSD Foundation
Fixes: 8f61992d7cc11
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D50153
(cherry picked from commit 2c65f965146a7f822302715a439e17996d17453c)