From: Lee Jones <lee@kernel.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Pavel Machek <pavel@kernel.org>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] leds: lp55xx: roll back engine sysfs group on failure
Date: Wed, 1 Jul 2026 22:54:40 +0100 [thread overview]
Message-ID: <20260701215440.GE2108533@google.com> (raw)
In-Reply-To: <20260615064913.58433-1-pengpeng@iscas.ac.cn>
On Mon, 15 Jun 2026, Pengpeng Hou wrote:
> lp55xx_register_sysfs() creates the common engine sysfs group before
> creating the optional chip-specific sysfs group.
>
> If the chip-specific group creation fails, the function returns the
> error directly and leaves the engine group published even though probe
> fails and the chip state will be torn down.
>
> Remove the engine group when the later chip-specific group creation
> fails.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> drivers/leds/leds-lp55xx-common.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
> index ea131177de96..501762b02667 100644
> --- <mark>drivers/leds/leds-lp55xx-common.c</mark>
> +++ b/drivers/leds/leds-lp55xx-common.c
> @@ -1090,6 +1090,7 @@ static int lp55xx_register_sysfs(struct lp55xx_chip *chip)
> {
> struct device *dev = &chip->cl->dev;
> const struct lp55xx_device_config *cfg = chip->cfg;
> + bool engine_group_created = false;
This is almost certainly a NACK.
> int ret;
>
> if (!cfg->run_engine || !cfg->firmware_cb)
> @@ -1098,10 +1099,17 @@ static int lp55xx_register_sysfs(struct lp55xx_chip *chip)
> ret = sysfs_create_group(&dev->kobj, &lp55xx_engine_attr_group);
> if (ret)
> return ret;
> + engine_group_created = true;
>
> dev_specific_attrs:
> - return cfg->dev_attr_group ?
> - sysfs_create_group(&dev->kobj, cfg->dev_attr_group) : 0;
> + if (!cfg->dev_attr_group)
> + return 0;
> +
> + ret = sysfs_create_group(&dev->kobj, cfg->dev_attr_group);
> + if (ret && engine_group_created)
3 things:
Firstly, doesn't the driver core unwind these for us if probe fails?
Secondly, isn't sysfs_remove_group() okay to call regardless?
And lastly, _even_ checking 'cfg->run_engine' and 'cfg->firmware_cb'
would be better than introducing a new random variable to track this.
> + sysfs_remove_group(&dev->kobj, &lp55xx_engine_attr_group);
> +
> + return ret;
> }
>
> static void lp55xx_unregister_sysfs(struct lp55xx_chip *chip)
> --
> 2.50.1 (Apple Git-155)
>
--
Lee Jones
prev parent reply other threads:[~2026-07-01 21:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 6:49 [PATCH] leds: lp55xx: roll back engine sysfs group on failure Pengpeng Hou
2026-07-01 21:54 ` Lee Jones [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260701215440.GE2108533@google.com \
--to=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=pengpeng@iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox