]> Pileus Git - ~andy/linux/commitdiff
mei: bus: do not overflow the device name buffer
authorTomas Winkler <tomas.winkler@intel.com>
Wed, 24 Jul 2013 13:22:59 +0000 (16:22 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2013 05:50:53 +0000 (22:50 -0700)
1. use strncmp for comparsion strncpy was used for copying
which may omit the final %NUL terminator
2. id->name is statically defined so we can use sizeof

Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/bus.c

index 9ecd49a7be1b33cac4ece186e35e3ebc255d9d78..a150a42ed4af4edb4a4375f9e07a322efe24d918 100644 (file)
@@ -47,7 +47,7 @@ static int mei_cl_device_match(struct device *dev, struct device_driver *drv)
        id = driver->id_table;
 
        while (id->name[0]) {
-               if (!strcmp(dev_name(dev), id->name))
+               if (!strncmp(dev_name(dev), id->name, sizeof(id->name)))
                        return 1;
 
                id++;
@@ -71,7 +71,7 @@ static int mei_cl_device_probe(struct device *dev)
 
        dev_dbg(dev, "Device probe\n");
 
-       strncpy(id.name, dev_name(dev), MEI_CL_NAME_SIZE);
+       strncpy(id.name, dev_name(dev), sizeof(id.name));
 
        return driver->probe(device, &id);
 }