strncpy() does not null-terminate its output buffer if the source string's
length is at least as large as its 'count' argument. We know that the
source and destination buffers are the same size and that the source buffer
is null-terminated, so just use strcpy().
This fixes a kernel BUG message that often occurred when strlen(devname)
was exactly IFNAMSIZ-1. In such a case, if
internal_dev_port.devname[IFNAMSIZ-1] happened to be nonzero, it would
eventually fail the following check in alloc_netdev_mq():
BUG_ON(strlen(name) >= sizeof(dev->name));
Bug #2722.
goto err_free_dp;
/* Set up our datapath device. */
- strncpy(internal_dev_port.devname, devname, IFNAMSIZ - 1);
+ BUILD_BUG_ON(sizeof(internal_dev_port.devname) != sizeof(devname));
+ strcpy(internal_dev_port.devname, devname);
internal_dev_port.flags = ODP_PORT_INTERNAL;
err = new_dp_port(dp, &internal_dev_port, ODPP_LOCAL);
if (err) {