Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp205438pxj; Tue, 18 May 2021 01:13:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbdAk6y7wAUQ54yHiwXh+eZKpd1DHyrXTLFqL6aXBz4GJvtRgoIwMHHH7uvOt4PFAGWnDY X-Received: by 2002:a6b:f815:: with SMTP id o21mr3173804ioh.0.1621325592643; Tue, 18 May 2021 01:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621325592; cv=none; d=google.com; s=arc-20160816; b=0Qpm36C17gJkN1mKEwCQqEOpA3zVVwUQqAKZbwxp/mokhDNAnyY5qw6+Yoo4l+LQty XncM2weI6PlvvCZuWgAjkwpzmBoKiHxBnRInFCqc7FRQzEEkiebeC8Lu1x3b611fByZN Q54fmaHgrBgazlKZ3qbNJ6BXPsLcQNA09r+mrif/Ua0lTMHzo0OrzSiL1voNfhTvxqVZ xPZgdCa92PWH35Prh/zxZ9gSy+TQBwYCLH1NJ7u/OIMJIOROsRG7R03u8yKUnth0fzVz K2FxeUuvDSLQPQgsFKGuulFAx0OHoNaR3A3/G7Gse+CTH4zRs6p33pXZC3umwrrb7Kmi nQZA== 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=K4YXw+OTlcEuuePPGvXvNj8LHfu3QUYgbo7+EBTm4hs=; b=N7UEt2qZQ2dKJX1qfAWFK8qWuv/xXYHsn2GQ1RjLDk22qMQtflibCrBcPZ8Q7XLgFw 4RS3GXKXvekn+YSpitTEuQrPseXnRxQj8QiXfqvPbYlTNnUanuhwF1+DAer+wQRNjLT/ +6gXq1zjvnILhvMG17xDbwSQ3Ul+IJdGodc/IBR0+ej2qDe3acHVZBC06/AdHdNMmxsl lEFgAWUBeVWI7yW3WRbQQoVS+0C3eylhxx+SiwQswvLvPgykc6Uf8BmBA9p5k5JbNVcL SCLrPbBm1dBpmutIi3gYqGJ69efyIYuAnrEioryDZUGlSPdzU6UyTYpN0KMyoSVd0nta ls9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="UpBq/Abv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 19si9944449ilg.27.2021.05.18.01.13.00; Tue, 18 May 2021 01:13:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="UpBq/Abv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S242060AbhEQO7O (ORCPT + 99 others); Mon, 17 May 2021 10:59:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:37900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242121AbhEQOt4 (ORCPT ); Mon, 17 May 2021 10:49:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E174561985; Mon, 17 May 2021 14:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261371; bh=um87pZxXXqt+kHc2F/4E0dxQC1yETfmXXG1blnyBF7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UpBq/AbvxF5Co+0IVtvLB3+nYhN3n0U/CsK6ILfPrfSBcIW60biOUELXrvCIdE4M7 j09Fq2jNRzznJ2ADul40NWBlnBtnnVXtXFQuOm9+mQCbEYkDYWk9H51PPwyHnusDQR O0yizVCnJlVhIXFsPL2y+UjrS3I+smQlWiRqE1/c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Aring , David Teigland , Sasha Levin Subject: [PATCH 5.10 013/289] fs: dlm: add errno handling to check callback Date: Mon, 17 May 2021 15:58:58 +0200 Message-Id: <20210517140305.625599557@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Aring [ Upstream commit 8aa9540b49e0833feba75dbf4f45babadd0ed215 ] This allows to return individual errno values for the config attribute check callback instead of returning invalid argument only. Signed-off-by: Alexander Aring Signed-off-by: David Teigland Signed-off-by: Sasha Levin --- fs/dlm/config.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/fs/dlm/config.c b/fs/dlm/config.c index 49c5f9407098..73e6643903af 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c @@ -125,7 +125,7 @@ static ssize_t cluster_cluster_name_store(struct config_item *item, CONFIGFS_ATTR(cluster_, cluster_name); static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, - int *info_field, bool (*check_cb)(unsigned int x), + int *info_field, int (*check_cb)(unsigned int x), const char *buf, size_t len) { unsigned int x; @@ -137,8 +137,11 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, if (rc) return rc; - if (check_cb && check_cb(x)) - return -EINVAL; + if (check_cb) { + rc = check_cb(x); + if (rc) + return rc; + } *cl_field = x; *info_field = x; @@ -161,14 +164,20 @@ static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \ } \ CONFIGFS_ATTR(cluster_, name); -static bool dlm_check_zero(unsigned int x) +static int dlm_check_zero(unsigned int x) { - return !x; + if (!x) + return -EINVAL; + + return 0; } -static bool dlm_check_buffer_size(unsigned int x) +static int dlm_check_buffer_size(unsigned int x) { - return (x < DEFAULT_BUFFER_SIZE); + if (x < DEFAULT_BUFFER_SIZE) + return -EINVAL; + + return 0; } CLUSTER_ATTR(tcp_port, dlm_check_zero); -- 2.30.2