summaryrefslogtreecommitdiff
path: root/com32/lib/pci/scan.c
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-11-09 10:42:10 +0100
committerErwan Velu <erwan.velu@free.fr>2009-11-09 10:42:10 +0100
commitfe18d4a75a7c5281188bff42c2bdbc53f1ec9ee8 (patch)
tree006e0f0ab69d805201138c6ababcef58f55995f1 /com32/lib/pci/scan.c
parent2adc666fb9ef812bcd7d509b2501ccaab00c4c22 (diff)
downloadsyslinux-fe18d4a75a7c5281188bff42c2bdbc53f1ec9ee8.tar.gz
pci: Prevent kernel modules to be listed twice
Impact: Prevent duplicated modules If both get_module_name_from_pcimap() & get_module_name_from_alias() are called, we didn't checked if the module we are detecting already got detected. This leads to a situation where modules got listed twice. This patch add a test to insure that we aren't adding an already detected module.
Diffstat (limited to 'com32/lib/pci/scan.c')
-rw-r--r--com32/lib/pci/scan.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c
index 82a7c844..55b178dd 100644
--- a/com32/lib/pci/scan.c
+++ b/com32/lib/pci/scan.c
@@ -154,8 +154,22 @@ int get_module_name_from_pcimap(struct pci_domain *domain,
== dev->sub_product &&
(int_sub_vendor_id & dev->sub_vendor)
== dev->sub_vendor) {
- strcpy(dev->dev_info->linux_kernel_module[dev->dev_info->linux_kernel_module_count], module_name);
- dev->dev_info->linux_kernel_module_count++;
+ bool found=false;
+
+ /* Scan all known kernel modules for this pci device */
+ for (int i=0; i<dev->dev_info->linux_kernel_module_count; i++) {
+
+ /* Try to detect if we already knew the same kernel module*/
+ if (strstr(dev->dev_info->linux_kernel_module[i], module_name)) {
+ found=true;
+ break;
+ }
+ }
+ /* If we don't have this kernel module, let's add it */
+ if (!found) {
+ strcpy(dev->dev_info->linux_kernel_module[dev->dev_info->linux_kernel_module_count], module_name);
+ dev->dev_info->linux_kernel_module_count++;
+ }
}
}
}
@@ -702,8 +716,22 @@ int get_module_name_from_alias(struct pci_domain *domain, char *modules_alias_pa
== dev->sub_product &&
(int_sub_vendor_id & dev->sub_vendor)
== dev->sub_vendor) {
- strcpy(dev->dev_info->linux_kernel_module[dev->dev_info->linux_kernel_module_count], module_name);
- dev->dev_info->linux_kernel_module_count++;
+ bool found=false;
+
+ /* Scan all known kernel modules for this pci device */
+ for (int i=0; i<dev->dev_info->linux_kernel_module_count; i++) {
+
+ /* Try to detect if we already knew the same kernel module*/
+ if (strstr(dev->dev_info->linux_kernel_module[i], module_name)) {
+ found=true;
+ break;
+ }
+ }
+ /* If we don't have this kernel module, let's add it */
+ if (!found) {
+ strcpy(dev->dev_info->linux_kernel_module[dev->dev_info->linux_kernel_module_count], module_name);
+ dev->dev_info->linux_kernel_module_count++;
+ }
}
}
}