bus/pci: fix error in parsing vfio driver
PATCH 1/1 bus/pci: fix error in parsing vfio driver
In pci_get_kernel_driver_by_path(), the available memory size of dri_name should be strlen(name + 1) + 1, not the size of the pointer (8 bytes), so "vfio-pci" is truncated to "vfio-pc" ended with number 0.
This patch fixes it.
--- drivers/bus/pci/linux/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/pci/linux/pci.c +1 -1
@@ -54,7 +54,7 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name) name =strrchr (path,'/' );if (name) { -strlcpy (dri_name, name +1 ,sizeof (dri_name)); +strlcpy (dri_name, name +1 ,strlen (name +1 ) +1 );return 0 ; }
Signature · 1 line
2.5.5
Give up this patch as there is already a patch
in http://dpdk.org/dev/patchwork/patch/40030/ bus/pci: correct the earlier strlcpy conversion
Quoted 38 lines
-----Original Message-----
From: Dai, Wei
Sent: Tuesday, May 15, 2018 10:41 PM
To: Yigit, Ferruh <[email protected]>; Burakov, Anatoly <[email protected]>
Cc: [email protected]; Dai, Wei <[email protected]>; [email protected]
Subject: [PATCH] bus/pci: fix error in parsing vfio driverIn
pci_get_kernel_driver_by_path(), the available memory size ofdri_nameshould be strlen(name + 1) + 1, not the size of the pointer (8 bytes), so "vfio-pci" is truncated to "vfio-pc"
ended with number 0.
This patch fixes it.Fixes fe5f777b5383 ("bus/pci: replace strncpy by strlcpy")Signed-off-by Wei Dai <[email protected]>--- drivers/bus/pci/linux/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/bus/pci/linux/pci.c index renamed from drivers/bus/pci/linux/pci.c +0
-0a73ee49..cc6b383 100644
drivers/bus/pci/linux/pci.c +1
-2@@ -54,7 +54,7 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name) name =strrchr (path,'/' );if (name) { -strlcpy (dri_name, name +1 ,sizeof (dri_name)); +strlcpy (dri_name, name +1 ,strlen (name +1 ) +1 );return 0 ; } --2.5.5