Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4486686rwb; Tue, 6 Sep 2022 08:10:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR5RnN8tW7eu6DtDEIIBozrOAe3K6aoBUqg5i/hNT0ZFIEfhOVpz07bkil6VQy2adc4jsify X-Received: by 2002:a05:6402:40b:b0:44e:6c5c:441b with SMTP id q11-20020a056402040b00b0044e6c5c441bmr9999226edv.223.1662477050427; Tue, 06 Sep 2022 08:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662477050; cv=none; d=google.com; s=arc-20160816; b=tpRiJ73XeJfx/1UJVokFOHP8bsQPtgM/w5h2M0zO7Rw896iTH87pNccS3g6Azu012N 4bw7Ertb7szLgsgiKuh+jaY0OKYHLpNl+z+54XTvWL1gv+uM5AJyQDJKhHTMiJkU0VmG h0FkhWG1MMnnfQ3GIOAVEpDfkP8HHlGmA/qWTjJ2CwQ9hhIFcIzeuSdJnziy0eutkgLb eWRtN1jl2MgeGe1kUu/Cmvwv1YhWXG2jLnqmgtdlIgan7hXwoa2QNjB/vKse+xckwSl4 9M9fBGlSpV8QPrij7cKhDzOou3Dc/DJAPSWl5+ch+DqX4l+jU4dM1ADEqkRTlzg+q8QA R7Jw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e2ca3yBaVrYDsUTSywiECXQotaXhTrXSvBUZwt9gRVE=; b=RiTRIKkSzxPi3O+CeeRRTJP0RoYZkAZ7V2dCbzZLGM8fL4dyGILEqN4vWwl0TTFiW5 PrC2S1XIY0WBsM6dhraICkFgQnzSaYXy/IzICM4ALEhhgUBwbQGSwR74UXZiYm8PZHKi OpQuejSdJr0YGnGv0erO9VAb4lfc1C4Q8C+oKWOBO94eNBPYtF5/+nlLRskaN5tTXfMl VXEbDvxX4e2+wmqEqO0VxpjsdXeEs/8j1XmhdkzmI8HrhufHZMaOzkCT2iAT1dmYeH7S 8xFfsP56C8oEK17sDUQGGqK4H9v4rifncAoxWIu4Vrl9cUrVubB61pF/x2unRAhtA8lv /6pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1dflreal; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb13-20020a0564020d0d00b004480d6fefe4si1188706edb.239.2022.09.06.08.10.24; Tue, 06 Sep 2022 08:10:50 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1dflreal; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239488AbiIFOFQ (ORCPT + 99 others); Tue, 6 Sep 2022 10:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241048AbiIFOCQ (ORCPT ); Tue, 6 Sep 2022 10:02:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7AAE1123; Tue, 6 Sep 2022 06:44:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 884AD6154D; Tue, 6 Sep 2022 13:43:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96E71C433D6; Tue, 6 Sep 2022 13:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471801; bh=4dlgeQLWQkdbkwYAH0LptfHKzlPXCb/0oVluVpxLKIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1dflrealMMM6G7OpvfdBXM8acEaMCJoA2/IridBsYuTCQKmLpcKI1MiY1XnspZB7u B5BvSZ/MrmRPJX2B/6CIDhodPUHhsKKE+PP3CQM4C+j+eUDaH0o30n5clpzxhWOAV1 M6T4ao0vlxbA58Ddzazqxluwh0e6bYFITQd7y24s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sun Ke , Jeffle Xu , Dan Carpenter , David Howells , Gao Xiang , Sasha Levin Subject: [PATCH 5.19 044/155] cachefiles: fix error return code in cachefiles_ondemand_copen() Date: Tue, 6 Sep 2022 15:29:52 +0200 Message-Id: <20220906132831.277055643@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Sun Ke [ Upstream commit c93ccd63b18c8d108c57b2bb0e5f3b058b9d2029 ] 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. Changes ======= v4: update the code suggested by Dan v3: update the commit log suggested by Jingbo. Fixes: c8383054506c ("cachefiles: notify the user daemon when looking up cookie") Signed-off-by: Sun Ke Suggested-by: Jeffle Xu Suggested-by: Dan Carpenter Signed-off-by: David Howells Reviewed-by: Gao Xiang Reviewed-by: Jingbo Xu Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/20220818111935.1683062-1-sunke32@huawei.com/ # v2 Link: https://lore.kernel.org/r/20220818125038.2247720-1-sunke32@huawei.com/ # v3 Link: https://lore.kernel.org/r/20220826023515.3437469-1-sunke32@huawei.com/ # v4 Signed-off-by: Sasha Levin --- 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 1fee702d55293..7e1586bd5cf34 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.35.1