Message ID | 1669377831-41386-2-git-send-email-wangyufen@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3954907wrr; Fri, 25 Nov 2022 03:54:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf4vQS/aMtp3UPdf0IPvO9dBhTxrCXTtCX08n9GstzM1xSRS5tL706qATbR1Gl9LF3oXL3ra X-Received: by 2002:a17:902:9882:b0:188:7a1f:fb18 with SMTP id s2-20020a170902988200b001887a1ffb18mr19174121plp.0.1669377295457; Fri, 25 Nov 2022 03:54:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669377295; cv=none; d=google.com; s=arc-20160816; b=k1WGsTdVJ4oKFtL29GZfv6vCGk9ng11yfesvogfW/VVJSX03rjgMhy2XW3t885718F DAjY5vQ5OAtGsL6ljkfTFLMJJJ/kdpif9dq0Z434GO0KCXAyYcvm1Z9hQDpRrbJtULQu CaWNvJlQGpeTnL+rC6znq6FkD251fBiZdz7adXog8q+ByRFQ51MfwWxXBmmOskjUcZcC sHdIEyScjh9Vz2yjfdhktP3Y/7s79/yr8VyKj7892RXAM+6Y5LpLJFGMpV81S7tGRXLb UB9m0TNJoFcoOF7F3uCSdkViz+Th7bJZkdhtnomkX9BGvr7DjLUy2v8yjm87dVH5CRTL Q9hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=CTsBAudpzw9qglm4FnxKpA1fz07hvhlcNrgY0BRmfF8=; b=ylUmU/vehVNq0Vtq9l3oiW0NWTY2pvWSGO61KHWXHw0PKcZSpGoo/UBa0NBfdBDtrJ v4AjZNd6Qrqji1kISr9px1OGMaszgv7vn78NJnSV593b1fiv7AwXBHHoNejcrVw2bAC4 BXoEnhlQmTlEJrOsR/JKEO1isbfJwB0tNPlUQJXHEgAHJAD2x7Kimijxm7Aymnlnrw/l YSZZuX7pI46XBFtquP9t+gnnv6bDtzOlY3cotVqR3SxRDxBUGs2oQGRRRRV8fCmiG2iu tzx0w1wfu8qWhsqBWqjY7Tts2L+c0LiPjaYcWtYq8r77rpiEbLPh9REeQ9RlOIj0lPQE 32Kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v189-20020a6389c6000000b004770fe91070si3865187pgd.587.2022.11.25.03.54.41; Fri, 25 Nov 2022 03:54:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229878AbiKYLns (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Fri, 25 Nov 2022 06:43:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbiKYLnq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 25 Nov 2022 06:43:46 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC14ABF6D; Fri, 25 Nov 2022 03:43:45 -0800 (PST) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NJXzs1kdfzHw7H; Fri, 25 Nov 2022 19:43:05 +0800 (CST) Received: from localhost.localdomain (10.175.112.70) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 25 Nov 2022 19:43:43 +0800 From: Wang Yufen <wangyufen@huawei.com> To: <bvanassche@acm.org>, <jgg@ziepe.ca>, <leon@kernel.org>, <dennis.dalessandro@cornelisnetworks.com> CC: <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <andriy.shevchenko@linux.intel.com>, <bart.vanassche@wdc.com>, <easwar.hariharan@intel.com>, Wang Yufen <wangyufen@huawei.com> Subject: [PATCH 2/2] RDMA/srp: Fix error return code in srp_parse_options() Date: Fri, 25 Nov 2022 20:03:51 +0800 Message-ID: <1669377831-41386-2-git-send-email-wangyufen@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669377831-41386-1-git-send-email-wangyufen@huawei.com> References: <1669377831-41386-1-git-send-email-wangyufen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500010.china.huawei.com (7.192.105.118) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750468966962668075?= X-GMAIL-MSGID: =?utf-8?q?1750468966962668075?= |
Series |
[1/2] RDMA/hfi1: Fix error return code in parse_platform_config()
|
|
Commit Message
wangyufen
Nov. 25, 2022, 12:03 p.m. UTC
In the previous while loop, "ret" may be assigned zero. Therefore,
"ret" needs to be assigned -EINVAL at the beginning of each loop.
Fixes: e711f968c49c ("IB/srp: replace custom implementation of hex2bin()")
Fixes: 2a174df0c602 ("IB/srp: Use kstrtoull() instead of simple_strtoull()")
Fixes: 19f313438c77 ("IB/srp: Add RDMA/CM support")
Signed-off-by: Wang Yufen <wangyufen@huawei.com>
---
drivers/infiniband/ulp/srp/ib_srp.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Fri, Nov 25, 2022 at 08:03:51PM +0800, Wang Yufen wrote: > In the previous while loop, "ret" may be assigned zero. Therefore, > "ret" needs to be assigned -EINVAL at the beginning of each loop. ... > while ((p = strsep(&sep_opt, ",\n")) != NULL) { > + ret = -EINVAL; > if (!*p) > continue; Better option is to investigate each case separately and gather all of them into a single fix. For example, this case SRP_OPT_MAX_IT_IU_SIZE: if (match_int(args, &token) || token < 0) { pr_warn("bad maximum initiator to target IU size '%s'\n", p); goto out; } target->max_it_iu_size = token; break; can be rewritten as case SRP_OPT_MAX_IT_IU_SIZE: ret = match_int(args, &token); if (ret) goto out; if (token < 0) { pr_warn("bad maximum initiator to target IU size '%s'\n", p); ret = -EINVAL; goto out; } target->max_it_iu_size = token; break; and so on...
在 2022/11/25 22:37, Andy Shevchenko 写道: > On Fri, Nov 25, 2022 at 08:03:51PM +0800, Wang Yufen wrote: >> In the previous while loop, "ret" may be assigned zero. Therefore, >> "ret" needs to be assigned -EINVAL at the beginning of each loop. > > ... > >> while ((p = strsep(&sep_opt, ",\n")) != NULL) { >> + ret = -EINVAL; >> if (!*p) >> continue; > > Better option is to investigate each case separately and gather all of them > into a single fix. > > For example, this > > case SRP_OPT_MAX_IT_IU_SIZE: > if (match_int(args, &token) || token < 0) { > pr_warn("bad maximum initiator to target IU size '%s'\n", p); > goto out; > } > target->max_it_iu_size = token; > break; > > can be rewritten as > > case SRP_OPT_MAX_IT_IU_SIZE: > ret = match_int(args, &token); > if (ret) > goto out; > if (token < 0) { > pr_warn("bad maximum initiator to target IU size '%s'\n", p); > ret = -EINVAL; > goto out; > } > target->max_it_iu_size = token; > break; > > and so on... > I got it. Will change in v2. Thanks!
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 1075c2a..1bd3559 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3352,6 +3352,7 @@ static int srp_parse_options(struct net *net, const char *buf, sep_opt = options; while ((p = strsep(&sep_opt, ",\n")) != NULL) { + ret = -EINVAL; if (!*p) continue;