Skip to content

Commit 8b613bb

Browse files
Tomas Winklergregkh
authored andcommitted
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>
1 parent 5290801 commit 8b613bb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/misc/mei/bus.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int mei_cl_device_match(struct device *dev, struct device_driver *drv)
4747
id = driver->id_table;
4848

4949
while (id->name[0]) {
50-
if (!strcmp(dev_name(dev), id->name))
50+
if (!strncmp(dev_name(dev), id->name, sizeof(id->name)))
5151
return 1;
5252

5353
id++;
@@ -71,7 +71,7 @@ static int mei_cl_device_probe(struct device *dev)
7171

7272
dev_dbg(dev, "Device probe\n");
7373

74-
strncpy(id.name, dev_name(dev), MEI_CL_NAME_SIZE);
74+
strncpy(id.name, dev_name(dev), sizeof(id.name));
7575

7676
return driver->probe(device, &id);
7777
}

0 commit comments

Comments
 (0)