From 0f07a24b4baf14859fde39b29bcc6fe279d18109 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 27 Jan 2008 18:14:51 +0100 Subject: 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 Acked-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-amd756.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/i2c/busses/i2c-amd756.c') 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, int error; u8 temp; + /* driver_data might come from user-space, so check it */ + if (id->driver_data > ARRAY_SIZE(chipname)) + return -EINVAL; + if (amd756_ioport) { dev_err(&pdev->dev, "Only one device supported " "(you have a strange motherboard, btw)\n"); @@ -405,6 +409,7 @@ static struct pci_driver amd756_driver = { .id_table = amd756_ids, .probe = amd756_probe, .remove = __devexit_p(amd756_remove), + .dynids.use_driver_data = 1, }; static int __init amd756_init(void) -- cgit v1.2.3