Received: by 10.192.165.148 with SMTP id m20csp1630645imm; Thu, 3 May 2018 02:47:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp8O3C0FlPbFdFruDGJf+KrLUfmjo/+8tGJ40URkmL+0bHZClrv9hbe1V5/ULoM7p7qquhS X-Received: by 2002:a17:902:ab86:: with SMTP id f6-v6mr22717295plr.185.1525340836358; Thu, 03 May 2018 02:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525340836; cv=none; d=google.com; s=arc-20160816; b=kKwBA2r8H1PesTCoq1taGtJjSXAt9vTKkqk/dM9NTlus7hpWG4dz+aOkeGd9pMTiNx hEVCx97NTuNua9h102BmMhL+UKnauiQE1LJTjvXrMIxDWZY13s1lR9Zc5V7260nMP7/X 7c+qAF8C6KeGaqWBnsl9Oty3hYa6EKaUrTw36/zBowSpzePjeMomFy4fxm68j0Bj6zLI RR+QYuOpWm4hCi6Q8eoOY925/8RJAG/f5keseMXgN5ElZ9krj/IheM0jWytlPdRIAI+D 6h34r5WMRUpar1ESzIc8Z2cIdxwqh+Ao3LrbCYoVVr848/osWlziPGMw4S3G00MAfJL4 iXEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=B8IuLe1QbGafXx1i15g/wj4SKSH6MROmCzDB+eb7BvE=; b=u52Ea/T0v7mnSHPFYI3rs2Tq1q9r1j4vnQ1n5EB/DeG3Ct7ymzOa9+O7+qchgGKKIU vuUv9nPJ7Q33OpSwOZR8KEraFSEplMF3L+kN6lC+dezaQCquHq7Z5kUnusDJTuueAEhs bGvzNgkcwebY71LUoO1db75OJmr+SCKuXqjzG/8q0CrODdf7YM08yQCk8lX0YNkvyQyI XxMBUHV/2IRUA9swCS15VGd5fnQW0YSr8dOeqGajZyAxcj0vtcYwbcPa4sCZtk44Pa4Q tgcQAqRw8xKvqJVIrNGckgff4ClkYZ/V8aMQY80OzB2W2cCGrZvS6vKEyP0JSvuZeChr FcmQ== 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 l65si11777644pfb.69.2018.05.03.02.47.02; Thu, 03 May 2018 02:47:16 -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 S1751528AbeECJpn (ORCPT + 99 others); Thu, 3 May 2018 05:45:43 -0400 Received: from mout.gmx.net ([212.227.17.22]:38779 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751160AbeECJp3 (ORCPT ); Thu, 3 May 2018 05:45:29 -0400 Received: from juanniu018037.ss.mogujie.org ([122.225.81.134]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Li0dC-1eZu5p0Yk6-00n5kJ; Thu, 03 May 2018 11:45:08 +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 1/2] net/9p: detecting invalid options as much as possible Date: Thu, 3 May 2018 17:44:35 +0800 Message-Id: <1525340676-34072-1-git-send-email-cgxu519@gmx.com> X-Mailer: git-send-email 1.8.3.1 X-Provags-ID: V03:K1:N5FBsrGKC4PMvW6gLQ0PdzTNmWNEQqh5gUegPbtdbfLM9MD0xI/ O+2mPSrCVRxufT2vQhzXUR2XHFr1Ln6naolUS0b0hI4I1eTWKGfl2uLKF/WCtuUrBMXpJ0r +KFoq47LelmKmAZjrfRJv3SEtPtlyu8t0nA44/D9PVxkqsRpJ86jndGMQAxvgaLvHBsW+8o aD24Of4WukTXZ+BIq89tw== X-UI-Out-Filterresults: notjunk:1;V01:K0:M3uHICW6JVw=:1X+8fFLCljsaTQFB/qNwfb UHkzL4BaJ9qL0p1Cdwc7y+0eVrZEoe8kjcD7Kd0XqCY/kGasCIrqNcMD/n7KgegEfb4hANZsr ge67s+CqF8y6gbZ082JzYvEZifexkqdrekp/vJAN3VLxgF32EqvLE1thpE2AJ0KDkZVCWvsX2 URTXPupyftbhzH6IKkiUupnIGDXVb97aEaKzId2tofs9n7cVsOte5NS7kvTGJRdY4E7bjIAyM LpftVi4WUUsX/7AClMq7y1hNIp2r0BaWAyUXxinVNZ0yma0m4CIjwVZ552m8I37Jqam5wy2h8 t5TTqmqvIhlg7YStrh7YQatN0gfP3ftI3tKIFoiuL1UiG9j3vGwLhFnUrjJ43QfcFuDJhuoAv OaHE4WOY4NOJ63DmuatTNrZsYg4mbMU0eTrDow6kpHi+YQ2vMMyPQnLRqVaIIF2BNbk7BX5rg 1dnNfDyFSrgOlinsNv80da18Z9fA914KS0/OljDK8Yl2DZXjQSTzBzTNOXBFG5QvxG/ijEXbf Cw5SXKyMeJXQ8eFk86pteStmCcMaUaIXX8FJ5AGutT876IrNt9QTlEh/q/HNpN3nPxQVOXE92 H8o9pJ6aMy6DgAa1rOF944VdM41DuVFF3Ub0UB7mjRGOlpfjgGXguCXeiFL/62hRt9bP9fXJD PZd9hbVi6sSa4YAimGAQt8zomb91kBTwmQo5RzkucM6IHFKfOuaMpY2qCt/+cVRSgzJmfpa5u rr55vWxpx3jiPKNh5fgBvjBEp3HJVxrsTiPQFSggnyKceSYTzEUf14OJz8E= 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 'trans' and 'version' when detecting -EINVAL. Signed-off-by: Chengguang Xu --- Changes since v2: - Introduce a new temporary variable to avoid overriding error code. Changes since v1: - Do not change behavior when detecting ENOMEM or unrecognized options. net/9p/client.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 21e6df1..18c5271 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -198,8 +198,6 @@ static int parse_opts(char *opts, struct p9_client *clnt) pr_info("Could not find request transport: %s\n", s); ret = -EINVAL; - kfree(s); - goto free_and_return; } kfree(s); break; @@ -214,13 +212,12 @@ static int parse_opts(char *opts, struct p9_client *clnt) "problem allocating copy of version arg\n"); goto free_and_return; } - ret = get_protocol_version(s); - if (ret == -EINVAL) { - kfree(s); - goto free_and_return; - } + r = get_protocol_version(s); + if (r < 0) + ret = r; + else + clnt->proto_version = r; kfree(s); - clnt->proto_version = ret; break; default: continue; -- 1.8.3.1