Received: by 10.192.165.148 with SMTP id m20csp1629634imm; Thu, 3 May 2018 02:46:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp7UYJxQWMqNq58tNsrOla8algcksHVd825QZJhhnypkQncuJRaMGaHFOouVTgfUZgv5UH2 X-Received: by 10.98.159.202 with SMTP id v71mr22399657pfk.233.1525340768563; Thu, 03 May 2018 02:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525340768; cv=none; d=google.com; s=arc-20160816; b=WHmRoyEHapuZODIo8yz5iZa8NbwwhAKteqAPOcWdSMkLKETtVAxBONLgxR6kWesfb7 zkTYNifivHoQp4U9sUx+lJDNc5ZnyVCpmMmtpKncOt3ZdF32/wLVuqTzDk2Kte1dzcPR 254L9kJOc0zM+Rb6fI3TXTUF03qus1LPIfsjWoXUSu8JMlWRLG08rKSrABzv2oZCsQKT L9Xslf9DvrNs1ma8PDadAWx7uELfFpW3qpEu9AUiLrCRCZTXK4vpp8wYD6bGQFWfA20k yzxJ3Pp4wWTtfvPgeJtExOWF6pLrMMBmOEXVKx2YTYXMueYRtM7lfwCz0WUMQtTQstGa 99wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=lJxhsj6vOEbX/WG/Gao7N18M6uzoezS4KaUGN9kjvlA=; b=NTXCh7naGkdJAxllKw07TyayNnNGvXkQC5IQd4JmhSCmZbwDcbCEgSZ45s/yvlL45p tvkw/jcC/kphu0WHg2vLK1yMqriZTNarYMxKww78lA3h+NkESmkc1TXjAS9Hb16AdTEg RmD2dKxLfpigd1CsQP6kJEENsIu0u+bSdh4LxENstNhDj/SlZN6FZJpmgt8AFeMkQZ/6 5QUTPG3VEbMVurTfeLwHYpeu6ujSVHNRW9Vfyq6CmWeyvhOyvOOd616CB8V2azpCRcFl 7XYziQh7Hp//2IqA0C6OFYUF22OQFQQut31/jN3tyRiY5a3511NEH/FdSVPAQ6OeQDZT RLTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 24si8068937pfp.161.2018.05.03.02.45.54; Thu, 03 May 2018 02:46:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751464AbeECJpj (ORCPT + 99 others); Thu, 3 May 2018 05:45:39 -0400 Received: from mout.gmx.net ([212.227.17.20]:52023 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbeECJpc (ORCPT ); Thu, 3 May 2018 05:45:32 -0400 Received: from juanniu018037.ss.mogujie.org ([122.225.81.134]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MdFwl-1ewEJD1P7r-00IY9C; Thu, 03 May 2018 11:45:17 +0200 From: Chengguang Xu To: akpm@linux-foundation.org, ericvh@gmail.com, rminnich@sandia.gov, lucho@ionkov.net Cc: v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chengguang Xu Subject: [V9fs-developer][PATCH v3 2/2] fs/9p: detecting invalid options as much as possible Date: Thu, 3 May 2018 17:44:36 +0800 Message-Id: <1525340676-34072-2-git-send-email-cgxu519@gmx.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525340676-34072-1-git-send-email-cgxu519@gmx.com> References: <1525340676-34072-1-git-send-email-cgxu519@gmx.com> X-Provags-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sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently when detecting invalid options in option parsing, some options(e.g. msize) just set errno and allow to continuously validate other options so that it can detect invalid options as much as possible and give proper error messages together. This patch applies same rule to option 'cache' and 'access' when detecting -EINVAL. Signed-off-by: Chengguang Xu --- Changes since v2: - Introduce a new temporary variable to avoid overriding error code. - Delete redundant continue in error case. Changes since v1: - Do not change behavior when detecting ENOMEM or unrecognized options. fs/9p/v9fs.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index e622f0f..0429c8e 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -210,12 +210,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) p9_debug(P9_DEBUG_ERROR, "integer field, but no integer?\n"); ret = r; - continue; - } - v9ses->debug = option; + } else { + v9ses->debug = option; #ifdef CONFIG_NET_9P_DEBUG - p9_debug_level = option; + p9_debug_level = option; #endif + } break; case Opt_dfltuid: @@ -231,7 +231,6 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) p9_debug(P9_DEBUG_ERROR, "uid field, but not a uid?\n"); ret = -EINVAL; - continue; } break; case Opt_dfltgid: @@ -247,7 +246,6 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) p9_debug(P9_DEBUG_ERROR, "gid field, but not a gid?\n"); ret = -EINVAL; - continue; } break; case Opt_afid: @@ -256,9 +254,9 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) p9_debug(P9_DEBUG_ERROR, "integer field, but no integer?\n"); ret = r; - continue; + } else { + v9ses->afid = option; } - v9ses->afid = option; break; case Opt_uname: kfree(v9ses->uname); @@ -306,13 +304,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) "problem allocating copy of cache arg\n"); goto free_and_return; } - ret = get_cache_mode(s); - if (ret == -EINVAL) { - kfree(s); - goto free_and_return; - } + r = get_cache_mode(s); + if (r < 0) + ret = r; + else + v9ses->cache = r; - v9ses->cache = ret; kfree(s); break; @@ -341,14 +338,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) pr_info("Unknown access argument %s\n", s); kfree(s); - goto free_and_return; + continue; } v9ses->uid = make_kuid(current_user_ns(), uid); if (!uid_valid(v9ses->uid)) { ret = -EINVAL; pr_info("Uknown uid %s\n", s); - kfree(s); - goto free_and_return; } } -- 1.8.3.1