From patchwork Wed Feb 3 21:15:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 76816 X-Patchwork-Delegate: ericvh@gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o13LQGa3005328 for ; Wed, 3 Feb 2010 21:26:52 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Ncmjf-0007I7-Pu; Wed, 03 Feb 2010 21:26:07 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.124] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Ncmje-0007Hx-2L for v9fs-developer@lists.sourceforge.net; Wed, 03 Feb 2010 21:26:06 +0000 X-ACL-Warn: Received: from e8.ny.us.ibm.com ([32.97.182.138]) by sfi-mx-4.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1Ncmjc-0002Oa-2J for v9fs-developer@lists.sourceforge.net; Wed, 03 Feb 2010 21:26:05 +0000 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e8.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o13H8mbB029879 for ; Wed, 3 Feb 2010 12:08:48 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o13LFbrB1167572 for ; Wed, 3 Feb 2010 16:15:37 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o13LFaIM024138 for ; Wed, 3 Feb 2010 16:15:37 -0500 Received: from [127.0.0.1] (IBM-2AECC81F76A.beaverton.ibm.com [9.47.22.70]) by d01av04.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o13LFUoi023802; Wed, 3 Feb 2010 16:15:35 -0500 Message-ID: <4B69E772.5010704@linux.vnet.ibm.com> Date: Wed, 03 Feb 2010 13:15:30 -0800 From: jvrao User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Sripathi Kodi References: <20100201223707.1dda3532@in.ibm.com> <4B676932.9010900@linux.vnet.ibm.com> <20100202162413.291265b9@in.ibm.com> In-Reply-To: <20100202162413.291265b9@in.ibm.com> X-Enigmail-Version: 0.96.0 X-Spam-Score: -2.0 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -4.0 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [32.97.182.138 listed in list.dnswl.org] 2.0 AWL AWL: From: address is in the auto white-list X-Headers-End: 1Ncmjc-0002Oa-2J Cc: ericvh@gmail.com, v9fs-developer@lists.sourceforge.net Subject: Re: [V9fs-developer] [RFC] [PATCH] 9P/Virtio: kernel panic in 'mount' command. 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: , Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 03 Feb 2010 21:26:52 +0000 (UTC) diff --git a/net/9p/client.c b/net/9p/client.c index 8af95b2..7d77c69 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -69,7 +69,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...); static int parse_opts(char *opts, struct p9_client *clnt) { - char *options; + char *options, *tmp_options; char *p; substring_t args[MAX_OPT_ARGS]; int option; @@ -81,12 +81,13 @@ static int parse_opts(char *opts, struct p9_client *clnt) if (!opts) return 0; - options = kstrdup(opts, GFP_KERNEL); - if (!options) { + tmp_options = kstrdup(opts, GFP_KERNEL); + if (!tmp_options) { P9_DPRINTK(P9_DEBUG_ERROR, "failed to allocate copy of option string\n"); return -ENOMEM; } + options = tmp_options; while ((p = strsep(&options, ",")) != NULL) { int token; @@ -94,12 +95,13 @@ static int parse_opts(char *opts, struct p9_client *clnt) continue; token = match_token(p, tokens, args); if (token < Opt_trans) { - int r = match_int(&args[0], &option); - if (r < 0) { + ret = match_int(&args[0], &option); + if (ret < 0) { P9_DPRINTK(P9_DEBUG_ERROR, "integer field, but no integer?\n"); - ret = r; - continue; + if (clnt->trans_mod) + v9fs_put_trans(clnt->trans_mod); + return ret; } } switch (token) { @@ -117,7 +119,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) } } - kfree(options); + kfree(tmp_options); return ret; } @@ -660,6 +662,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) err = 0; clnt = kmalloc(sizeof(struct p9_client), GFP_KERNEL); + if (!clnt) return ERR_PTR(-ENOMEM); @@ -667,18 +670,12 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) clnt->trans = NULL; spin_lock_init(&clnt->lock); INIT_LIST_HEAD(&clnt->fidlist); - clnt->fidpool = p9_idpool_create(); - if (IS_ERR(clnt->fidpool)) { - err = PTR_ERR(clnt->fidpool); - clnt->fidpool = NULL; - goto error; - } p9_tag_init(clnt); err = parse_opts(options, clnt); if (err < 0) - goto error; + goto free_client; if (!clnt->trans_mod) clnt->trans_mod = v9fs_get_default_trans(); @@ -687,7 +684,14 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) err = -EPROTONOSUPPORT; P9_DPRINTK(P9_DEBUG_ERROR, "No transport defined or default transport\n"); - goto error; + goto free_client; + } + + clnt->fidpool = p9_idpool_create(); + if (IS_ERR(clnt->fidpool)) { + err = PTR_ERR(clnt->fidpool); + clnt->fidpool = NULL; + goto put_trans; } P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n", @@ -695,19 +699,25 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) err = clnt->trans_mod->create(clnt, dev_name, options); if (err) - goto error; + goto destroy_fidpool; if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize) clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ; err = p9_client_version(clnt); if (err) - goto error; + goto close_trans; return clnt; -error: - p9_client_destroy(clnt); +close_trans: + clnt->trans_mod->close(clnt); +destroy_fidpool: + p9_idpool_destroy(clnt->fidpool); +put_trans: + v9fs_put_trans(clnt->trans_mod); +free_client: + kfree(clnt); return ERR_PTR(err); } EXPORT_SYMBOL(p9_client_create);