summaryrefslogtreecommitdiffstats
path: root/sys/ofed/include
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2013-07-08 21:25:12 +0000
committerjhb <jhb@FreeBSD.org>2013-07-08 21:25:12 +0000
commit3297db39d56073deb3fd4d2b69fce426ac837803 (patch)
tree060f342f7e42541239236a5072f1e3bd4fcda99e /sys/ofed/include
parent581b7760a59c50e55860392e73bf9c7cb3caef21 (diff)
downloadFreeBSD-src-3297db39d56073deb3fd4d2b69fce426ac837803.zip
FreeBSD-src-3297db39d56073deb3fd4d2b69fce426ac837803.tar.gz
Allow mlx4 devices to switch from Ethernet to Infiniband (and vice versa):
- Fix sysctl wrapper for sysfs attributes to properly handle new string values similar to sysctl_handle_string() (only copyin the user's supplied length and nul-terminate the string). - Don't check for a trailing newline when evaluating the desired operating mode of a mlx4 device. PR: kern/179999 Submitted by: Shahar Klein <shahark@mellanox.com> MFC after: 1 week
Diffstat (limited to 'sys/ofed/include')
-rw-r--r--sys/ofed/include/linux/sysfs.h9
1 files changed, 7 insertions, 2 deletions
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:
OpenPOWER on IntegriCloud