diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2013-07-24 09:22:59 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-25 01:50:53 -0400 |
commit | 8b613bb86a3d4a106c9a8f6de3d8a4c3628ea998 (patch) | |
tree | 1fedee9ea5b7f72f5db444fdbce40ba9e0cc11a9 /drivers/misc/mei/bus.c | |
parent | 5290801c23231c8e192943d3beb01fdbeb536395 (diff) |
mei: bus: do not overflow the device name buffer
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>
Diffstat (limited to 'drivers/misc/mei/bus.c')
-rw-r--r-- | drivers/misc/mei/bus.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 9ecd49a7be1b..a150a42ed4af 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c | |||
@@ -47,7 +47,7 @@ static int mei_cl_device_match(struct device *dev, struct device_driver *drv) | |||
47 | id = driver->id_table; | 47 | id = driver->id_table; |
48 | 48 | ||
49 | while (id->name[0]) { | 49 | while (id->name[0]) { |
50 | if (!strcmp(dev_name(dev), id->name)) | 50 | if (!strncmp(dev_name(dev), id->name, sizeof(id->name))) |
51 | return 1; | 51 | return 1; |
52 | 52 | ||
53 | id++; | 53 | id++; |
@@ -71,7 +71,7 @@ static int mei_cl_device_probe(struct device *dev) | |||
71 | 71 | ||
72 | dev_dbg(dev, "Device probe\n"); | 72 | dev_dbg(dev, "Device probe\n"); |
73 | 73 | ||
74 | strncpy(id.name, dev_name(dev), MEI_CL_NAME_SIZE); | 74 | strncpy(id.name, dev_name(dev), sizeof(id.name)); |
75 | 75 | ||
76 | return driver->probe(device, &id); | 76 | return driver->probe(device, &id); |
77 | } | 77 | } |