Re: Re: [PATCH] cifs: fix pointer initialization and checks in cifs_follow_symlink (try #3)

Christoph Hellwig <[email protected]>
Newsgroups gmane.linux.file-systems.cifs
Message-ID <[email protected]>
On Tue, May 19, 2009 at 10:00:37AM -0400, Jeff Layton wrote:
> diff --git a/fs/cifs/link.c b/fs/cifs/link.c
> index ea9d11e..cd83c53 100644
> --- a/fs/cifs/link.c
> +++ b/fs/cifs/link.c
> @@ -107,48 +107,48 @@ void *
>  cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
>  {
>  	struct inode *inode = direntry->d_inode;
> +	int rc = -ENOMEM;
>  	int xid;
>  	char *full_path = NULL;
> +	char *target_path = NULL;
> +	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
> +	struct cifsTconInfo *tcon = cifs_sb->tcon;
>  
>  	xid = GetXid();
>  
> +	/*
> +	 * For now, we just handle symlinks with unix extensions enabled.
> +	 * Eventually we should handle NTFS reparse points, and MacOS
> +	 * symlink support. For instance...
> +	 *
> +	 * rc = CIFSSMBQueryReparseLinkInfo(...)
> +	 *
> +	 * For now, just return -EACCES when the server doesn't support posix
> +	 * extensions. Note that we still allow querying symlinks when posix
> +	 * extensions are manually disabled. We could disable these as well
> +	 * but there doesn't seem to be any harm in allowing the client to
> +	 * read them.
> +	 */
> +	if (!(tcon->ses->capabilities & CAP_UNIX)) {
> +		rc = -EACCES;
> +		goto out;
> +	}
>  
> +	full_path = build_path_from_dentry(direntry);
>  	if (!full_path)
>  		goto out;
>  
>  	cFYI(1, ("Full path: %s inode = 0x%p", full_path, inode));
>  
> +	rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, &target_path,
> +				     cifs_sb->local_nls);
> +	kfree(full_path);
> +out:
>  	if (rc != 0) {
>  		kfree(target_path);
>  		target_path = ERR_PTR(rc);
>  	}

Looks good.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.