Re: [PATCH 2/4] configfs: Do not override creating attribute file failure in populate_attrs()
From: Joel Becker
Date: Tue Apr 08 2025 - 18:14:34 EST
On Tue, Apr 08, 2025 at 09:26:08PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>
> populate_attrs() may override failure for creating attribute files
> by success for creating subsequent bin attribute files, and have
> wrong return value.
>
> Fix by creating bin attribute files under successfully creating
> attribute files.
>
> Fixes: 03607ace807b ("configfs: implement binary attributes")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
Reviewed-by: Joel Becker <jlbec@xxxxxxxxxxxx>
> ---
> fs/configfs/dir.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
> index 0a011bdad98c492227859ff328d61aeed2071e24..64272d3946cc40757dca063190829958517eceb3 100644
> --- a/fs/configfs/dir.c
> +++ b/fs/configfs/dir.c
> @@ -619,7 +619,7 @@ static int populate_attrs(struct config_item *item)
> break;
> }
> }
> - if (t->ct_bin_attrs) {
> + if (!error && t->ct_bin_attrs) {
> for (i = 0; (bin_attr = t->ct_bin_attrs[i]) != NULL; i++) {
> if (ops && ops->is_bin_visible && !ops->is_bin_visible(item, bin_attr, i))
> continue;
>
> --
> 2.34.1
>
--
Life's Little Instruction Book #511
"Call your mother."
http://www.jlbec.org/
jlbec@xxxxxxxxxxxx