From patchwork Wed Dec 22 13:02:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "M. Mohan Kumar" X-Patchwork-Id: 427091 X-Patchwork-Delegate: ericvh@gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBMDF4MY017277 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 22 Dec 2010 13:15:26 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1PVOWh-0006TI-I5; Wed, 22 Dec 2010 13:14:43 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1PVOWg-0006TB-1Q for v9fs-developer@lists.sourceforge.net; Wed, 22 Dec 2010 13:14:42 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of in.ibm.com designates 202.81.31.147 as permitted sender) client-ip=202.81.31.147; envelope-from=mohan@in.ibm.com; helo=e23smtp05.au.ibm.com; Received: from e23smtp05.au.ibm.com ([202.81.31.147]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) id 1PVOWe-0005Gz-Ap for v9fs-developer@lists.sourceforge.net; Wed, 22 Dec 2010 13:14:41 +0000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245]) by e23smtp05.au.ibm.com (8.14.4/8.13.1) with ESMTP id oBMCv0hK006885 for ; Wed, 22 Dec 2010 23:57:00 +1100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oBMD29ge2265204 for ; Thu, 23 Dec 2010 00:02:09 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oBMD29O4029861 for ; Thu, 23 Dec 2010 00:02:09 +1100 Received: from explorer.in.ibm.com (Kumod-009124035029.in.ibm.com [9.124.35.29]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id oBMD28Vk029851; Thu, 23 Dec 2010 00:02:08 +1100 From: "M. Mohan Kumar" To: v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 22 Dec 2010 18:32:07 +0530 Message-Id: <1293022927-27141-1-git-send-email-mohan@in.ibm.com> X-Mailer: git-send-email 1.7.1 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1PVOWe-0005Gz-Ap Subject: [V9fs-developer] [PATCH] fs/9p: TREADLINK fix X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 22 Dec 2010 13:15:26 +0000 (UTC) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 2ce3668..9d3b910 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1995,26 +1995,26 @@ error: } static int -v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen) +v9fs_vfs_readlink_dotl(struct dentry *dentry, char __user *buffer, int buflen) { - int retval; + int retval = -EPERM; struct p9_fid *fid; char *target = NULL; P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name); - retval = -EPERM; fid = v9fs_fid_lookup(dentry); if (IS_ERR(fid)) return PTR_ERR(fid); - retval = p9_client_readlink(fid, &target); if (retval < 0) - return retval; - - strncpy(buffer, target, buflen); - P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer); - - retval = strnlen(buffer, buflen); + goto error; + retval = copy_to_user(buffer, target, buflen); + if (retval < 0) + goto error; + P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, target); + retval = strnlen(target, buflen); +error: + kfree(target); return retval; } @@ -2028,23 +2028,22 @@ v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen) static void * v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd) { - int len = 0; - char *link = __getname(); + int retval; + struct p9_fid *fid; + char *link = NULL; P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name); - if (!link) - link = ERR_PTR(-ENOMEM); - else { - len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX); - if (len < 0) { - __putname(link); - link = ERR_PTR(len); - } else - link[min(len, PATH_MAX-1)] = 0; + fid = v9fs_fid_lookup(dentry); + if (IS_ERR(fid)) + return fid; + retval = p9_client_readlink(fid, &link); + if (retval < 0) { + kfree(link); + link = ERR_PTR(retval); } - nd_set_link(nd, link); + nd_set_link(nd, link); return NULL; }