Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: allow pci driver to support only dynids

commit b41d6cf38e27 (PCI: Check dynids driver_data value for validity)
requires all drivers to include an id table to try and match
driver_data. Before validating driver_data check driver has an id
table.

Acked-by: Jean Delvare <khali@linux-fr.org>
Cc: Milton Miller <miltonm@bga.com>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

authored by

Chris Wright and committed by
Jesse Barnes
2debb4d2 56ee325e

+11 -9
+11 -9
drivers/pci/pci-driver.c
··· 48 48 subdevice=PCI_ANY_ID, class=0, class_mask=0; 49 49 unsigned long driver_data=0; 50 50 int fields=0; 51 - int retval; 51 + int retval=0; 52 52 53 53 fields = sscanf(buf, "%x %x %x %x %x %x %lx", 54 54 &vendor, &device, &subvendor, &subdevice, ··· 58 58 59 59 /* Only accept driver_data values that match an existing id_table 60 60 entry */ 61 - retval = -EINVAL; 62 - while (ids->vendor || ids->subvendor || ids->class_mask) { 63 - if (driver_data == ids->driver_data) { 64 - retval = 0; 65 - break; 61 + if (ids) { 62 + retval = -EINVAL; 63 + while (ids->vendor || ids->subvendor || ids->class_mask) { 64 + if (driver_data == ids->driver_data) { 65 + retval = 0; 66 + break; 67 + } 68 + ids++; 66 69 } 67 - ids++; 70 + if (retval) /* No match */ 71 + return retval; 68 72 } 69 - if (retval) /* No match */ 70 - return retval; 71 73 72 74 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 73 75 if (!dynid)