summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-08-23 17:59:13 +0000
committerOlivier Blin <oblin@mandriva.com>2007-08-23 17:59:13 +0000
commit920066e41f3a1c46d37a7441ba22999c3d688fe0 (patch)
tree50c37c039ea5af2b2ff4165a5d897b2c0c9eb201 /mdk-stage1
parent2f0c18091bf86cabe44d0b6d90c1f4fd79f84994 (diff)
downloaddrakx-920066e41f3a1c46d37a7441ba22999c3d688fe0.tar
drakx-920066e41f3a1c46d37a7441ba22999c3d688fe0.tar.gz
drakx-920066e41f3a1c46d37a7441ba22999c3d688fe0.tar.bz2
drakx-920066e41f3a1c46d37a7441ba22999c3d688fe0.tar.xz
drakx-920066e41f3a1c46d37a7441ba22999c3d688fe0.zip
factorize code in a new device_match_modules_list() function and thus fix segfault in USB detection code (when e->module is NULL, #32624)
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/NEWS2
-rw-r--r--mdk-stage1/probing.c50
2 files changed, 24 insertions, 28 deletions
diff --git a/mdk-stage1/NEWS b/mdk-stage1/NEWS
index 6f48d9132..1f592552a 100644
--- a/mdk-stage1/NEWS
+++ b/mdk-stage1/NEWS
@@ -1,3 +1,5 @@
+- fix segfault in USB detection code (when no module match, #32624)
+
1.13:
- use module names instead of filenames
- convert module name to filename before loading it
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index adb6c4861..fab0f5d02 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -129,6 +129,16 @@ char * get_net_intf_description(char * intf_name)
}
#endif
+static int device_match_modules_list(struct pciusb_entry *e, char **modules, unsigned int modules_len) {
+ int i;
+ if (!e->module)
+ return 0;
+ for (i = 0; i < modules_len; i++)
+ if (!strcmp(modules[i], e->module))
+ return 1;
+ return 0;
+}
+
struct pcitable_entry *detected_devices = NULL;
int detected_devices_len = 0;
@@ -171,17 +181,11 @@ static void add_detected_device(unsigned short vendor, unsigned short device, un
static int add_detected_device_if_match(struct pciusb_entry *e, char **modules, unsigned int modules_len)
{
- int i;
- if (!e->module)
- return 0;
- for (i = 0; i < modules_len; i++) {
- if (!strcmp(modules[i], e->module)) {
- add_detected_device(e->vendor, e->device, e->subvendor, e->subdevice,
- e->text, e->module);
- return 1;
- }
- }
- return 0;
+ int ret = device_match_modules_list(e, modules, modules_len);
+ if (ret)
+ add_detected_device(e->vendor, e->device, e->subvendor, e->subdevice,
+ e->text, e->module);
+ return ret;
}
void probing_detect_devices()
@@ -340,16 +344,10 @@ void probe_that_type(enum driver_type type, enum media_bus bus __attribute__ ((u
entries = pci_probe();
for (i = 0; i < entries.nb; i++) {
struct pciusb_entry *e = &entries.entries[i];
- int j;
- if (!e->module)
- continue;
- for (j = 0; j < pci_modules_len; j++) {
- if (!strcmp(pci_modules[j], e->module)) {
- log_message("PCI: device %04x %04x %04x %04x is \"%s\", driver is %s",
- e->vendor, e->device, e->subvendor, e->subdevice, e->text, e->module);
- discovered_device(type, e->text, e->module);
- break;
- }
+ if (device_match_modules_list(e, pci_modules, pci_modules_len)) {
+ log_message("PCI: device %04x %04x %04x %04x is \"%s\", driver is %s",
+ e->vendor, e->device, e->subvendor, e->subdevice, e->text, e->module);
+ discovered_device(type, e->text, e->module);
}
}
pciusb_free(&entries);
@@ -389,13 +387,9 @@ void probe_that_type(enum driver_type type, enum media_bus bus __attribute__ ((u
entries = usb_probe();
for (i = 0; i < entries.nb; i++) {
struct pciusb_entry *e = &entries.entries[i];
- int j;
- for (j = 0; j < usb_modules_len; j++) {
- if (!strcmp(usb_modules[j], e->module)) {
- log_message("USB: device %04x %04x is \"%s\" (%s)", e->vendor, e->device, e->text, e->module);
- discovered_device(type, e->text, e->module);
- continue;
- }
+ if (device_match_modules_list(e, usb_modules, usb_modules_len)) {
+ log_message("USB: device %04x %04x is \"%s\" (%s)", e->vendor, e->device, e->text, e->module);
+ discovered_device(type, e->text, e->module);
}
}
pciusb_free(&entries);