bus/pci: fix hardware ID limit on Windows

Length of hardware IDs list is limited by REGSTR_VAL_MAX_HCID_LEN [1],
which is currently 1024. With the old limit of 260, obtaining the list
could fail in a rare occasion of a very long result (no examples known).
This also removes a bogus dependency on the maximum path length.

[1]: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/hardware-ids

Fixes: b762221ac2 ("bus/pci: support Windows with bifurcated drivers")
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
This commit is contained in:
Dmitry Kozlyuk 2020-12-11 23:09:30 +03:00 committed by Thomas Monjalon
parent 9d620630ea
commit 6d10ddb408

View File

@ -10,6 +10,7 @@
#include "pci_netuio.h" #include "pci_netuio.h"
#include <devpkey.h> #include <devpkey.h>
#include <regstr.h>
#if defined RTE_TOOLCHAIN_GCC && (__MINGW64_VERSION_MAJOR < 8) #if defined RTE_TOOLCHAIN_GCC && (__MINGW64_VERSION_MAJOR < 8)
#include <devpropdef.h> #include <devpropdef.h>
@ -303,7 +304,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
{ {
struct rte_pci_device *dev; struct rte_pci_device *dev;
int ret = -1; int ret = -1;
char pci_device_info[PATH_MAX]; char pci_device_info[REGSTR_VAL_MAX_HCID_LEN];
struct rte_pci_addr addr; struct rte_pci_addr addr;
struct rte_pci_id pci_id; struct rte_pci_id pci_id;
@ -314,7 +315,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
memset(dev, 0, sizeof(*dev)); memset(dev, 0, sizeof(*dev));
ret = get_pci_hardware_id(dev_info, device_info_data, ret = get_pci_hardware_id(dev_info, device_info_data,
pci_device_info, PATH_MAX); pci_device_info, sizeof(pci_device_info));
if (ret != 0) if (ret != 0)
goto end; goto end;