Re: [PATCH 1/5] gpio: aggregator: fix "_sysfs" prefix check in gpio_aggregator_make_group()
From: Geert Uytterhoeven
Date: Mon Apr 14 2025 - 03:53:07 EST
Hi Dan,
On Sat, 12 Apr 2025 at 12:15, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> This code is intended to reject strings that start with "_sysfs" but the
> strcmp() limit is wrong so checks the whole string instead of the prefix.
>
> Fixes: 83c8e3df642f ("gpio: aggregator: expose aggregator created via legacy sysfs to configfs")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> --- a/drivers/gpio/gpio-aggregator.c
> +++ b/drivers/gpio/gpio-aggregator.c
> @@ -1016,7 +1016,7 @@ gpio_aggregator_make_group(struct config_group *group, const char *name)
> * for devices create via legacy sysfs interface.
> */
> if (strncmp(name, AGGREGATOR_LEGACY_PREFIX,
> - sizeof(AGGREGATOR_LEGACY_PREFIX)) == 0)
> + sizeof(AGGREGATOR_LEGACY_PREFIX) - 1) == 0)
Or perhaps just strlen()? The compiler should optimize that to a constant, too.
> return ERR_PTR(-EINVAL);
>
> /* arg space is unneeded */
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds