Re: [PATCH v6 04/19] device property: Fix fwnode_name_eq() for empty node names
From: Bartosz Golaszewski
Date: Wed Nov 25 2026 - 11:10:55 EST
On Sat, Nov 14, 2026 at 04:22:16PM +0100, Alejandro Colomar wrote:
> str_has_prefix() returns the prefix length on match and 0 on mismatch,
> so the mistmatch case can't be told from "empty prefix matched an empty
> string".
>
> For instance: the OF root node's name as returned by
> fwnode_get_name() is "" and will return 0 for any name matched against
> it and since len is 0 too, fwnode_name_eq() will return true.
>
> Let's use strprefix() instead, which also makes this function simpler.
>
> Fixes: a9c8c738066b7 ("device property: Add fwnode_name_eq()")
> Closes: https://lore.kernel.org/linux-hardening/20261104-fwnode-for-each-prop-v1-1-6e28fe1c72c4@xxxxxxxxxxxxxxxx/
> Reported-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> Signed-off-by: Alejandro Colomar <alx@xxxxxxxxxx>
> ---
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
Tested-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
This series has grown substantially since v1. My GPIO series[1] depends on
fwnode_name_eq() working correctly so I would really appreciate it if we
could queue the bits and pieces fixing fwnode_name_eq() separately and sooner
rather than later (it should also be backported to stable).
Thanks
Bartosz
[1] https://lore.kernel.org/all/20261120-fwnode-for-each-prop-v3-0-808e304dc73e@xxxxxxxxxxxxxxxx/