Re: [PATCH v6 04/19] device property: Fix fwnode_name_eq() for empty node names
From: Sakari Ailus
Date: Mon Nov 16 2026 - 04:52:25 EST
Hi Alejandro,
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: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
--
Regards,
Sakari Ailus