aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/pci-driver.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index d911e0c1f359..650ce8935fd7 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -107,7 +107,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
107 subdevice=PCI_ANY_ID, class=0, class_mask=0; 107 subdevice=PCI_ANY_ID, class=0, class_mask=0;
108 unsigned long driver_data=0; 108 unsigned long driver_data=0;
109 int fields=0; 109 int fields=0;
110 int retval; 110 int retval = 0;
111 111
112 fields = sscanf(buf, "%x %x %x %x %x %x %lx", 112 fields = sscanf(buf, "%x %x %x %x %x %x %lx",
113 &vendor, &device, &subvendor, &subdevice, 113 &vendor, &device, &subvendor, &subdevice,
@@ -115,6 +115,26 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
115 if (fields < 2) 115 if (fields < 2)
116 return -EINVAL; 116 return -EINVAL;
117 117
118 if (fields != 7) {
119 struct pci_dev *pdev = kzalloc(sizeof(*pdev), GFP_KERNEL);
120 if (!pdev)
121 return -ENOMEM;
122
123 pdev->vendor = vendor;
124 pdev->device = device;
125 pdev->subsystem_vendor = subvendor;
126 pdev->subsystem_device = subdevice;
127 pdev->class = class;
128
129 if (pci_match_id(pdrv->id_table, pdev))
130 retval = -EEXIST;
131
132 kfree(pdev);
133
134 if (retval)
135 return retval;
136 }
137
118 /* Only accept driver_data values that match an existing id_table 138 /* Only accept driver_data values that match an existing id_table
119 entry */ 139 entry */
120 if (ids) { 140 if (ids) {