diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-01-27 12:14:51 -0500 |
---|---|---|
committer | Jean Delvare <khali@hyperion.delvare> | 2008-01-27 12:14:51 -0500 |
commit | 0f07a24b4baf14859fde39b29bcc6fe279d18109 (patch) | |
tree | 0ff3b88a1435a37480e9203dcca91482fb1dba3c | |
parent | b7a3670131c7662415fa799700fc0bdfe90a54b6 (diff) |
i2c: Let the user specify PCI driver data through new_id
The i2c-amd756 and i2c-viapro drivers make use of the driver_data
field of the PCI device ID. When adding device IDs dynamically (by
writing to the new_id sysfs file) you cannot set the value of this
field by default. It has to be allowed explicitly. Do that, and
check the value so that the user can't crash the kernel accidentally.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/i2c/busses/i2c-amd756.c | 5 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-viapro.c | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 7490dc1771ae..573abe440842 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -334,6 +334,10 @@ static int __devinit amd756_probe(struct pci_dev *pdev, | |||
334 | int error; | 334 | int error; |
335 | u8 temp; | 335 | u8 temp; |
336 | 336 | ||
337 | /* driver_data might come from user-space, so check it */ | ||
338 | if (id->driver_data > ARRAY_SIZE(chipname)) | ||
339 | return -EINVAL; | ||
340 | |||
337 | if (amd756_ioport) { | 341 | if (amd756_ioport) { |
338 | dev_err(&pdev->dev, "Only one device supported " | 342 | dev_err(&pdev->dev, "Only one device supported " |
339 | "(you have a strange motherboard, btw)\n"); | 343 | "(you have a strange motherboard, btw)\n"); |
@@ -405,6 +409,7 @@ static struct pci_driver amd756_driver = { | |||
405 | .id_table = amd756_ids, | 409 | .id_table = amd756_ids, |
406 | .probe = amd756_probe, | 410 | .probe = amd756_probe, |
407 | .remove = __devexit_p(amd756_remove), | 411 | .remove = __devexit_p(amd756_remove), |
412 | .dynids.use_driver_data = 1, | ||
408 | }; | 413 | }; |
409 | 414 | ||
410 | static int __init amd756_init(void) | 415 | static int __init amd756_init(void) |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index c9ce77f13c0e..661ebc7a711e 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -318,6 +318,10 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
318 | unsigned char temp; | 318 | unsigned char temp; |
319 | int error = -ENODEV; | 319 | int error = -ENODEV; |
320 | 320 | ||
321 | /* driver_data might come from user-space, so check it */ | ||
322 | if (id->driver_data & 1 || id->driver_data > 0xff) | ||
323 | return -EINVAL; | ||
324 | |||
321 | /* Determine the address of the SMBus areas */ | 325 | /* Determine the address of the SMBus areas */ |
322 | if (force_addr) { | 326 | if (force_addr) { |
323 | vt596_smba = force_addr & 0xfff0; | 327 | vt596_smba = force_addr & 0xfff0; |
@@ -455,6 +459,7 @@ static struct pci_driver vt596_driver = { | |||
455 | .name = "vt596_smbus", | 459 | .name = "vt596_smbus", |
456 | .id_table = vt596_ids, | 460 | .id_table = vt596_ids, |
457 | .probe = vt596_probe, | 461 | .probe = vt596_probe, |
462 | .dynids.use_driver_data = 1, | ||
458 | }; | 463 | }; |
459 | 464 | ||
460 | static int __init i2c_vt596_init(void) | 465 | static int __init i2c_vt596_init(void) |