diff options
Diffstat (limited to 'sys/ofed')
-rw-r--r-- | sys/ofed/drivers/net/mlx4/main.c | 6 | ||||
-rw-r--r-- | sys/ofed/include/linux/sysfs.h | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/sys/ofed/drivers/net/mlx4/main.c b/sys/ofed/drivers/net/mlx4/main.c index fe1f4bf..b48dfbd 100644 --- a/sys/ofed/drivers/net/mlx4/main.c +++ b/sys/ofed/drivers/net/mlx4/main.c @@ -479,11 +479,11 @@ static ssize_t set_port_type(struct device *dev, int i; int err = 0; - if (!strcmp(buf, "ib\n")) + if (!strcmp(buf, "ib")) info->tmp_type = MLX4_PORT_TYPE_IB; - else if (!strcmp(buf, "eth\n")) + else if (!strcmp(buf, "eth")) info->tmp_type = MLX4_PORT_TYPE_ETH; - else if (!strcmp(buf, "auto\n")) + else if (!strcmp(buf, "auto")) info->tmp_type = MLX4_PORT_TYPE_AUTO; else { mlx4_err(mdev, "%s is not supported port type\n", buf); diff --git a/sys/ofed/include/linux/sysfs.h b/sys/ofed/include/linux/sysfs.h index 698f75e..ca2d71e 100644 --- a/sys/ofed/include/linux/sysfs.h +++ b/sys/ofed/include/linux/sysfs.h @@ -104,10 +104,15 @@ sysctl_handle_attr(SYSCTL_HANDLER_ARGS) error = SYSCTL_OUT(req, buf, len); if (error || !req->newptr || ops->store == NULL) goto out; - error = SYSCTL_IN(req, buf, PAGE_SIZE); + len = req->newlen - req->newidx; + if (len >= PAGE_SIZE) + error = EINVAL; + else + error = SYSCTL_IN(req, buf, len); if (error) goto out; - len = ops->store(kobj, attr, buf, req->newlen); + ((char *)buf)[len] = '\0'; + len = ops->store(kobj, attr, buf, len); if (len < 0) error = -len; out: |