Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3242314rwb; Wed, 30 Nov 2022 17:54:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf7A8StBgzy/1QVy6L5oTbxr8NlPdbbQP3a1+UO7ZnTyUuYS0t7N+FeOxkFJJQ5RZ/e2YLlu X-Received: by 2002:a17:906:40f:b0:7bb:8647:e0e4 with SMTP id d15-20020a170906040f00b007bb8647e0e4mr29033307eja.652.1669859674752; Wed, 30 Nov 2022 17:54:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669859674; cv=none; d=google.com; s=arc-20160816; b=mBhV50G2KyJbgpRK7xwYMD0TSPBDbcA7j/8+aYwqNulvbxjKRCQ2Nd32KSbo0L0fzG R5a4rQVTZfGwyx6dI7Hire5yKDn6GbZSnDwHhBX75L2OWPhKrJoOFlGzXQoGpU2iWJrY AoY6O+fldo3CcB5Fh+wBfph1vmVdCGr/mVqaGKOfzhx4pGRq6Cw69upW89RguxNlj9w5 ITHqmTzNH7WakGO3VqcjTiPJ3jMlDwKHgOjY0LbAbGmo8kI88OSH4pR1JDylwcMmZPvh 91FqHAgCktFDkJ3eDH0j9ogrQ4IXULbutdrJeeq1kaM5DKQ9JU6RI+uvtZvPaIbfSuHu MYyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=XaiCiO2fks9OmI/zeXcIu8XBGLJ0DFWLpcFeHr7GiOU=; b=fyWfV7Lv90rcTuOm8MSYjoEbfXgVKKHrTVvBkB6ZoPGjjhCs71qvQGUxuwaqQuIXEx QdYzOk2imrxkw721I2w0G+gqThK3eOu5NFKH/eSkmPjwPNSoAXfml4jxKinCwz/JU/nm sGWR1+5gBvJw/QpRxOv1k5ns002mQMT+T/HncAJMZw+FBY4Uck+J/IDMS7E9T7q5ds1p kFwKHgAnkfvVsWK/dE0X22sWVbqPsUj1pkYJyulxyiCMb1YlnBirIVJdwkQQ8FBWpQiS i7J+H5jLjGquT5aoDEd0LLDnZKVaDCWrK7Di4RlmCLnZg8PSmWYb+Lm5k/oAzHF9OXR1 NaJA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp27-20020a1709071b1b00b00781c1645926si2725164ejc.524.2022.11.30.17.54.07; Wed, 30 Nov 2022 17:54:34 -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 S229854AbiLABt5 (ORCPT + 83 others); Wed, 30 Nov 2022 20:49:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbiLABtz (ORCPT ); Wed, 30 Nov 2022 20:49:55 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E82D1F0; Wed, 30 Nov 2022 17:49:54 -0800 (PST) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NMzWp6rzvzmWKj; Thu, 1 Dec 2022 09:49:10 +0800 (CST) Received: from [10.174.179.191] (10.174.179.191) 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; Thu, 1 Dec 2022 09:49:52 +0800 Message-ID: <0b726968-bfb8-ab9a-8d03-4d072d410597@huawei.com> Date: Thu, 1 Dec 2022 09:49:51 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v4 2/2] RDMA/srp: Fix error return code in srp_parse_options() To: Bart Van Assche , , , CC: , , , , References: <1669687459-14180-1-git-send-email-wangyufen@huawei.com> <1669687459-14180-2-git-send-email-wangyufen@huawei.com> <65604aae-b722-4caf-3373-d0f1e4492faa@huawei.com> <1d27a774-cf83-6e36-4fa1-c0635ebfd79e@acm.org> From: wangyufen In-Reply-To: <1d27a774-cf83-6e36-4fa1-c0635ebfd79e@acm.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.191] 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.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/12/1 2:00, Bart Van Assche 写道: > On 11/29/22 19:31, wangyufen wrote: >> I'm so sorry for the poor patch description. Is the following >> description OK? >> >> In the previous iteration of the while loop, "ret" may have been >> assigned a value of 0, so the error return code -EINVAL may have been >> incorrectly set to 0. >> Also, investigate each case separately as Andy suggessted. If the help >> function match_int() fails, the error code is returned, which is >> different from the warning information printed before. If the parsing >> result token is incorrect, "-EINVAL" is returned and the original >> warning information is printed. > > Please reply below instead of above. See also > https://en.wikipedia.org/wiki/Posting_style. > > Regarding your question: not logging an error message if user input is > rejected is unfriendly to the user. I think it's better to keep the > behavior of reporting an error if a match* function fails instead of > reporting in the patch description that the behavior has changed. > So the following modification is better? case SRP_OPT_CMD_SG_ENTRIES: - if (match_int(args, &token) || token < 1 || token > 255) { + ret = match_int(args, &token); + if (ret) { + pr_warn("bad max cmd_sg_entries parameter '%s'\n", + p); + goto out; + } + if (token < 1 || token > 255) { pr_warn("bad max cmd_sg_entries parameter '%s'\n", p); + ret = -EINVAL; goto out; } target->cmd_sg_cnt = token; break; Or the following is better? if (match_int(args, &token) || token < 1 || token > 255) { pr_warn("bad max cmd_sg_entries parameter '%s'\n", p); + ret = -EINVAL; goto out; } target->cmd_sg_cnt = token; break; > Thanks, > > Bart. > >