Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0f07a24b4baf14859fde39b29bcc6fe279d18109
Commit:     0f07a24b4baf14859fde39b29bcc6fe279d18109
Parent:     b7a3670131c7662415fa799700fc0bdfe90a54b6
Author:     Jean Delvare <[EMAIL PROTECTED]>
AuthorDate: Sun Jan 27 18:14:51 2008 +0100
Committer:  Jean Delvare <[EMAIL PROTECTED]>
CommitDate: Sun Jan 27 18:14:51 2008 +0100

    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 <[EMAIL PROTECTED]>
    Acked-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 drivers/i2c/busses/i2c-amd756.c |    5 +++++
 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 7490dc1..573abe4 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)
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index c9ce77f..661ebc7 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,
        unsigned char temp;
        int error = -ENODEV;
 
+       /* driver_data might come from user-space, so check it */
+       if (id->driver_data & 1 || id->driver_data > 0xff)
+               return -EINVAL;
+
        /* Determine the address of the SMBus areas */
        if (force_addr) {
                vt596_smba = force_addr & 0xfff0;
@@ -455,6 +459,7 @@ static struct pci_driver vt596_driver = {
        .name           = "vt596_smbus",
        .id_table       = vt596_ids,
        .probe          = vt596_probe,
+       .dynids.use_driver_data = 1,
 };
 
 static int __init i2c_vt596_init(void)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to