From owner-svn-src-all@FreeBSD.ORG Mon Jul 8 21:25:13 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 91345536; Mon, 8 Jul 2013 21:25:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 692A219F9; Mon, 8 Jul 2013 21:25:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68LPDeS023496; Mon, 8 Jul 2013 21:25:13 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r68LPDlY023493; Mon, 8 Jul 2013 21:25:13 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201307082125.r68LPDlY023493@svn.freebsd.org> From: John Baldwin Date: Mon, 8 Jul 2013 21:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253048 - in head/sys/ofed: drivers/net/mlx4 include/linux X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 21:25:13 -0000 Author: jhb Date: Mon Jul 8 21:25:12 2013 New Revision: 253048 URL: http://svnweb.freebsd.org/changeset/base/253048 Log: 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 MFC after: 1 week Modified: head/sys/ofed/drivers/net/mlx4/main.c head/sys/ofed/include/linux/sysfs.h Modified: head/sys/ofed/drivers/net/mlx4/main.c ============================================================================== --- head/sys/ofed/drivers/net/mlx4/main.c Mon Jul 8 21:17:20 2013 (r253047) +++ head/sys/ofed/drivers/net/mlx4/main.c Mon Jul 8 21:25:12 2013 (r253048) @@ -479,11 +479,11 @@ static ssize_t set_port_type(struct devi 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); Modified: head/sys/ofed/include/linux/sysfs.h ============================================================================== --- head/sys/ofed/include/linux/sysfs.h Mon Jul 8 21:17:20 2013 (r253047) +++ head/sys/ofed/include/linux/sysfs.h Mon Jul 8 21:25:12 2013 (r253048) @@ -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: