From patchwork Tue Dec 21 07:15:39 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: 423661 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 oBL7GDPD027031 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 21 Dec 2010 07:16:35 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 1PUwRr-0002d9-5J; Tue, 21 Dec 2010 07:15:51 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1PUwRp-0002d2-R1 for v9fs-developer@lists.sourceforge.net; Tue, 21 Dec 2010 07:15:49 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of in.ibm.com designates 122.248.162.9 as permitted sender) client-ip=122.248.162.9; envelope-from=mohan@in.ibm.com; helo=e28smtp09.in.ibm.com; Received: from e28smtp09.in.ibm.com ([122.248.162.9]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) id 1PUwRo-000113-GN for v9fs-developer@lists.sourceforge.net; Tue, 21 Dec 2010 07:15:49 +0000 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by e28smtp09.in.ibm.com (8.14.4/8.13.1) with ESMTP id oBL6bLwt021655 for ; Tue, 21 Dec 2010 12:07:21 +0530 Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oBL7Fdjl4091954 for ; Tue, 21 Dec 2010 12:45:39 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oBL7FdQu028478 for ; Tue, 21 Dec 2010 18:15:39 +1100 Received: from localhost.localdomain ([9.122.21.145]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id oBL7FdBv028467 for ; Tue, 21 Dec 2010 18:15:39 +1100 From: "M. Mohan Kumar" To: v9fs-developer@lists.sourceforge.net Date: Tue, 21 Dec 2010 12:45:39 +0530 Message-Id: <1292915739-13660-1-git-send-email-mohan@in.ibm.com> X-Mailer: git-send-email 1.7.0.4 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: 1PUwRo-000113-GN Subject: [V9fs-developer] [PATCH] fs/9p: TREADLINK bugfix 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]); Tue, 21 Dec 2010 07:16:35 +0000 (UTC) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 34bf71b..27c7b93 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -2001,26 +2001,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; } @@ -2034,23 +2034,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; }