Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1257693rwe; Thu, 25 Aug 2022 20:06:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kF1he7um7Rf2lyCElqonZODYDwWk/FKA7hVRpNLmcSd2X8f45WV6iouheIIcsu4PAl/wr X-Received: by 2002:aa7:838a:0:b0:536:101a:9ccf with SMTP id u10-20020aa7838a000000b00536101a9ccfmr1961993pfm.18.1661483189856; Thu, 25 Aug 2022 20:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661483189; cv=none; d=google.com; s=arc-20160816; b=B+INKwUs/Uj4fnQScMQVCgVAB3Wb/CSIeRE7vd7C1PlUlFrHpBKktGS58twAvsKEAW ctI1t80DqtVY5SMUoD2sWOvUx0l7s23YEMWcKMAt2HpiImD1miFkCRmVR4kftHJhDvkz NaChMmpiYCo6/116ox27ntVzR9JMJ3U7Uh7Mut1zbXVVm6527fv536LADGKecsyMHB1V RLOsZ12weHiSR+IdoOQvW6SRNPlbZ8MbqATsRDRzxSY3JPVSY3wSEFrAsdiKqYeZWgRD HnJkY1jT/ulH0df+O0xUadHsrYomiMnsL8BftPMuBYy+Z48OS/rwOFoXTaqnjJVQXUGQ pHaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=1xdc4hp+2ABZaQSsQkeH6RSbd6Rsy8XbFXwCROUfy78=; b=dZ6mUE9NF6oqTk/piwJxe6su9Kc6XNPmo7NKIIOny+/DtmoPSVUOX+kbWRjRFqr/Sm S+vAkeQfjxZszZ79CRtAd5qXs9NYs0YotD/D1egh421nT2w/BAWqcQZHCoP8HlzqnEXf ZQ048qbQRggkgS4lFrZBoj5vfpu/+d121rNoO5ECxwcPTyT1lkU+iApR/LlifJXjbhNj ly8/lhBKdHIFuPBynIkjiXGb/TdmxNR6tZRrhm+UG3+hsWL2XB/Y32Pf3Ny8vxX5Z+sl XK6YZSI7AABtLW4o7nJxRQJWBurlPwrhWSXhs+XzeRh6M4+rXzfPruKOMqNLxAn1y5tG 3SSQ== 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 s68-20020a637747000000b0041e10ee0ed6si643121pgc.379.2022.08.25.20.06.19; Thu, 25 Aug 2022 20:06:29 -0700 (PDT) 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 S244533AbiHZCX5 (ORCPT + 99 others); Thu, 25 Aug 2022 22:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbiHZCX4 (ORCPT ); Thu, 25 Aug 2022 22:23:56 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C2FC924C; Thu, 25 Aug 2022 19:23:55 -0700 (PDT) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MDNpr6tX9zlWMm; Fri, 26 Aug 2022 10:20:36 +0800 (CST) Received: from kwepemm600010.china.huawei.com (7.193.23.86) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 10:23:53 +0800 Received: from huawei.com (10.175.127.227) by kwepemm600010.china.huawei.com (7.193.23.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 10:23:52 +0800 From: Sun Ke To: CC: , , , , , , , Subject: [PATCH v4] cachefiles: fix error return code in cachefiles_ondemand_copen() Date: Fri, 26 Aug 2022 10:35:15 +0800 Message-ID: <20220826023515.3437469-1-sunke32@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600010.china.huawei.com (7.193.23.86) 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,T_SCC_BODY_TEXT_LINE 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 The cache_size field of copen is specified by the user daemon. If cache_size < 0, then the OPEN request is expected to fail, while copen itself shall succeed. However, returning 0 is indeed unexpected when cache_size is an invalid error code. Fix this by returning error when cache_size is an invalid error code. Fixes: c8383054506c ("cachefiles: notify the user daemon when looking up cookie") Signed-off-by: Sun Ke Suggested-by: Jeffle Xu Suggested-by: Dan Carpenter --- v4: update the code suggested by Dan v3: update the commit log suggested by Jingbo. fs/cachefiles/ondemand.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c index 1fee702d5529..7e1586bd5cf3 100644 --- a/fs/cachefiles/ondemand.c +++ b/fs/cachefiles/ondemand.c @@ -158,9 +158,13 @@ int cachefiles_ondemand_copen(struct cachefiles_cache *cache, char *args) /* fail OPEN request if daemon reports an error */ if (size < 0) { - if (!IS_ERR_VALUE(size)) - size = -EINVAL; - req->error = size; + if (!IS_ERR_VALUE(size)) { + req->error = -EINVAL; + ret = -EINVAL; + } else { + req->error = size; + ret = 0; + } goto out; } -- 2.31.1