Re: [PATCH 1/4] NFS: Use common device name parsing logic for NFSv4 and NFSv2/v3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2008-06-17 at 16:33 -0400, Trond Myklebust wrote:
> On Tue, 2008-06-17 at 14:17 -0400, Chuck Lever wrote:
> > To support passing a raw IPv6 address as a server hostname, we need to
> > expand the logic that handles splitting the passed-in device name into
> > a server hostname and export path
> > 
> > Start by pulling device name parsing out of the mount option validation
> > functions and into separate helper functions.
> > 
> > Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
> > ---
> > 
> >  fs/nfs/super.c |  124 ++++++++++++++++++++++++++++++++++++--------------------
> >  1 files changed, 79 insertions(+), 45 deletions(-)
> > 
> > 
> > diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> > index d884f52..5e0eefa 100644
> > --- a/fs/nfs/super.c
> > +++ b/fs/nfs/super.c
> > @@ -1216,6 +1216,67 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args,
> >  }
> >  
> >  /*
> > + * Split "dev_name" into "hostname:export_path".
> > + *
> > + * Note: caller frees hostname and export path, even on error.
> > + */
> > +static int nfs_parse_devname(const char *dev_name,
> > +			     char **hostname, size_t maxnamlen,
> > +			     char **export_path, size_t maxpathlen)
> > +{
> > +	size_t len;
> > +	char *colon, *comma;
> > +
> > +	colon = strchr(dev_name, ':');
> > +	if (colon == NULL)
> > +		goto out_bad_devname;
> > +
> > +	len = colon - dev_name;
> > +	if (len > maxnamlen)
> > +		goto out_hostname;
> > +
> > +	/* N.B. caller will free nfs_server.hostname in all cases */
> > +	*hostname = kstrndup(dev_name, len, GFP_KERNEL);
> > +	if (!*hostname)
> > +		goto out_nomem;
> > +
> > +	/* kill possible hostname list: not supported */
> > +	comma = strchr(*hostname, ',');
> > +	if (comma != NULL) {
> > +		if (comma == *hostname)
> > +			goto out_bad_devname;
> 
> Won't this and subsequent errors leak memory in *hostname?

Sorry. I missed the fact that nfs_get_sb() and nfs4_get_sb() will do it
for us...

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@xxxxxxxxxx
www.netapp.com
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux