Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1780310rwb; Tue, 29 Nov 2022 19:43:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4X6XxTaSmEjvwhOQwrjdirUO5WWfa9AgoMAXojSDZOi9+/IkOEqIcO/upa6KW1R50LcrtU X-Received: by 2002:a05:6402:1107:b0:463:9b53:cbf6 with SMTP id u7-20020a056402110700b004639b53cbf6mr46675083edv.173.1669779828278; Tue, 29 Nov 2022 19:43:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669779828; cv=none; d=google.com; s=arc-20160816; b=M/wJIh4WstJsYBRl57zVFZRXMot2SX2D/bQy0WKTAVaa8XFRHc4MDA5hOfJPzLhTDt wLfPH+jz3P1FPhUHR9ygnzp9y0WkN2oDo1PJpCa2fF7vKhBDD1z/c6YIxPfXfuRi4ZLu dKbCKUgH9g50Nu/9hchOS0EwAGpN1m8ks5OvjQ7NJ+iHl3voXIpOoq3s9rqLGsazOdFq VV24Jp0vvdzk/ihuENiNcIIYHZbs/XK9cx9RT3aUnjM/3ux3aqe/DRt1ItSXM5nF0llo LUKOP8qQgpeJWd1nF1SrTL6531jCIFgCVsaIQOSrKNSWVC/gGfbrbucWowbPF3Ew1q0P OGjg== 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=vjUiNOBV1Gsjg24+vLlF9zGVjQAw1BXbGvtsJrCeZhE=; b=ySvYQ34+DAPplQIgJ64IcY2x3KHT0GuYH1s5+x5hKRfYTd5DXeKiFI5WRGP8Ag46I1 JE2qZ/AypIwKofLik61IMb5Blrst6wXC0212weagCmLLDEmRyHx9bLYA4UHMRgl1hWqo kGMSTnakQyFsh5VjiJs96adShlzTWmLAqFukv2zBsa6mm25A2/SbK7uCdO80dPMhVtBP 0hhKwRINbtlF85T8u8LT1oMfcq7FzEUNtA19zGOdlqrdV7RatdGnQBpUOjm5eC3lRs1I RPBgPaN93dBsJmgrnMdkl81PF/iFEsac0mpUtmVRJrDLp8gy7wsE5GivwTG77/0+S202 NaLg== 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 dt13-20020a170907728d00b00781d82a6fc9si412946ejc.264.2022.11.29.19.43.28; Tue, 29 Nov 2022 19:43:48 -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 S231716AbiK3Dbi (ORCPT + 85 others); Tue, 29 Nov 2022 22:31:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbiK3Dbg (ORCPT ); Tue, 29 Nov 2022 22:31:36 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5C6B5ADE1; Tue, 29 Nov 2022 19:31:34 -0800 (PST) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NMPqZ4gj3zHwDs; Wed, 30 Nov 2022 11:30:50 +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; Wed, 30 Nov 2022 11:31:32 +0800 Message-ID: <65604aae-b722-4caf-3373-d0f1e4492faa@huawei.com> Date: Wed, 30 Nov 2022 11:31:32 +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> From: wangyufen In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.191] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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 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. Thanks. 在 2022/11/30 2:43, Bart Van Assche 写道: > On 11/28/22 18:04, Wang Yufen wrote: >> In the previous while loop, "ret" may be assigned zero, , so the error > > The word "iteration" is missing from the above sentence. Additionally, > there is a double comma. > >> return code may be incorrectly set to 0 instead of -EINVAL. Alse > > Alse -> Also > >>           case SRP_OPT_QUEUE_SIZE: >> -            if (match_int(args, &token) || token < 1) { >> +            ret = match_int(args, &token); >> +            if (ret) >> +                goto out; >> +            if (token < 1) { >>                   pr_warn("bad queue_size parameter '%s'\n", p); >> +                ret = -EINVAL; >>                   goto out; >>               } >>               target->scsi_host->can_queue = token; > > Why only to report "bad queue_size parameter" if ret == 0 && token < 1 > but not if ret < 0? This is a behavior change that has not been > explained in the patch description. > >> @@ -3490,25 +3496,34 @@ static int srp_parse_options(struct net *net, >> const char *buf, >>               break; >>           case SRP_OPT_MAX_CMD_PER_LUN: >> -            if (match_int(args, &token) || token < 1) { >> +            ret = match_int(args, &token); >> +            if (ret) >> +                goto out; >> +            if (token < 1) { >>                   pr_warn("bad max cmd_per_lun parameter '%s'\n", >>                       p); >> +                ret = -EINVAL; >>                   goto out; >>               } >>               target->scsi_host->cmd_per_lun = token; >>               break; > > Same comment here and for many other changes below. > > Thanks, > > Bart. > >