Commit:     6ba186361ed2cda7e174856a3ab8a8e3237b3c3d
Parent:     40ee9e9f8d52d85f2446bbdda7823a3f1de62f3f
Author:     Jean Delvare <[EMAIL PROTECTED]>
AuthorDate: Sat Apr 7 17:21:28 2007 +0200
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Wed May 2 19:02:35 2007 -0700

    PCI: Require vendor and device for new_id
    Currently, there is no minimum number of fields required when adding
    a new device ID to a PCI driver through the new_id sysfs file. It is
    possible to add a new ID with only the vendor ID set, causing the
    driver to attempt to attach to all PCI devices from that vendor. This
    has been reported to happen accidentally:
    It is even possible to not even set the vendor ID field, causing the
    driver to attempt to attach to _all_ the PCI devices.
    This sounds dangerous and I fail to see any valid use of this
    "feature". Thus I suggest that we now require at least the first two
    fields (vendor ID and device ID) to be set. For what it's worth, this
    is what the USB subsystem does.
    Signed-off-by: Jean Delvare <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
 Documentation/pci.txt    |    6 +++---
 drivers/pci/pci-driver.c |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/pci.txt b/Documentation/pci.txt
index cdf2f3c..a8ded1a 100644
--- a/Documentation/pci.txt
+++ b/Documentation/pci.txt
@@ -163,9 +163,9 @@ echo "vendor device subvendor subdevice class class_mask 
driver_data" > \
 All fields are passed in as hexadecimal values (no leading 0x).
-Users need pass only as many fields as necessary:
-       o vendor, device, subvendor, and subdevice fields default
-         to PCI_ANY_ID (FFFFFFFF),
+The vendor and device fields are mandatory, the others are optional. Users
+need pass only as many optional fields as necessary:
+       o subvendor and subdevice fields default to PCI_ANY_ID (FFFFFFFF)
        o class and classmask fields default to 0
        o driver_data defaults to 0UL.
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 39e80fc..07fdb3c 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -52,7 +52,7 @@ store_new_id(struct device_driver *driver, const char *buf, 
size_t count)
        struct pci_dynid *dynid;
        struct pci_driver *pdrv = to_pci_driver(driver);
-       __u32 vendor=PCI_ANY_ID, device=PCI_ANY_ID, subvendor=PCI_ANY_ID,
+       __u32 vendor, device, subvendor=PCI_ANY_ID,
                subdevice=PCI_ANY_ID, class=0, class_mask=0;
        unsigned long driver_data=0;
        int fields=0;
@@ -61,7 +61,7 @@ store_new_id(struct device_driver *driver, const char *buf, 
size_t count)
        fields = sscanf(buf, "%x %x %x %x %x %x %lux",
                        &vendor, &device, &subvendor, &subdevice,
                        &class, &class_mask, &driver_data);
-       if (fields < 0)
+       if (fields < 2)
                return -EINVAL;
        dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
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

Reply via email to