[V2] of: property: fw_devlink: fixup return value check of strcmp_suffix in parse_gpios

Message ID 1894edd07ee.b7245352142935.3234373322799059936@linux.beauty
State New
Headers
Series [V2] of: property: fw_devlink: fixup return value check of strcmp_suffix in parse_gpios |

Commit Message

Li Chen July 13, 2023, 10:47 a.m. UTC
  This commit addresses an issue where enabling fw_devlink=on was causing
a PCIe malfunction, resulting in endpoints missing.
After thorough investigation, it was determined that the root cause was
an incorrect usage of strcmp_suffix in parse_gpios.

Fixes: d473d32c2fba ("of: property: fw_devlink: do not link ".*,nr-gpios"")
Signed-off-by: Li Chen <lchen@ambarella.com>
Cc: stable@vger.kernel.org
---
changes:
v1->v2: add Cc stable

 drivers/of/property.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Rob Herring July 13, 2023, 4:45 p.m. UTC | #1
On Thu, Jul 13, 2023 at 4:47 AM Li Chen <me@linux.beauty> wrote:
>
> This commit addresses an issue where enabling fw_devlink=on was causing
> a PCIe malfunction, resulting in endpoints missing.
> After thorough investigation, it was determined that the root cause was
> an incorrect usage of strcmp_suffix in parse_gpios.
>
> Fixes: d473d32c2fba ("of: property: fw_devlink: do not link ".*,nr-gpios"")
> Signed-off-by: Li Chen <lchen@ambarella.com>
> Cc: stable@vger.kernel.org
> ---
> changes:
> v1->v2: add Cc stable
>
>  drivers/of/property.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index ddc75cd50825..261eb8f3be08 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
> @@ -1272,7 +1272,7 @@ DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")
>  static struct device_node *parse_gpios(struct device_node *np,
>                                        const char *prop_name, int index)
>  {
> -       if (!strcmp_suffix(prop_name, ",nr-gpios"))
> +       if (strcmp_suffix(prop_name, ",nr-gpios"))

strcmp returns 0 when there is a match. When we match ",nr-gpios", we
want to bail out. The existing code was correct. Your patch just
disables fw_devlink for all GPIO dependencies.

Rob
  
Li Chen July 14, 2023, 7:53 a.m. UTC | #2
Hi Rob,
 ---- On Fri, 14 Jul 2023 00:45:24 +0800  Rob Herring  wrote --- 
 > On Thu, Jul 13, 2023 at 4:47 AM Li Chen me@linux.beauty> wrote:
 > >
 > > This commit addresses an issue where enabling fw_devlink=on was causing
 > > a PCIe malfunction, resulting in endpoints missing.
 > > After thorough investigation, it was determined that the root cause was
 > > an incorrect usage of strcmp_suffix in parse_gpios.
 > >
 > > Fixes: d473d32c2fba ("of: property: fw_devlink: do not link ".*,nr-gpios"")
 > > Signed-off-by: Li Chen lchen@ambarella.com>
 > > Cc: stable@vger.kernel.org
 > > ---
 > > changes:
 > > v1->v2: add Cc stable
 > >
 > >  drivers/of/property.c | 2 +-
 > >  1 file changed, 1 insertion(+), 1 deletion(-)
 > >
 > > diff --git a/drivers/of/property.c b/drivers/of/property.c
 > > index ddc75cd50825..261eb8f3be08 100644
 > > --- a/drivers/of/property.c
 > > +++ b/drivers/of/property.c
 > > @@ -1272,7 +1272,7 @@ DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")
 > >  static struct device_node *parse_gpios(struct device_node *np,
 > >                                        const char *prop_name, int index)
 > >  {
 > > -       if (!strcmp_suffix(prop_name, ",nr-gpios"))
 > > +       if (strcmp_suffix(prop_name, ",nr-gpios"))
 > 
 > strcmp returns 0 when there is a match. When we match ",nr-gpios", we
 > want to bail out. The existing code was correct. Your patch just
 > disables fw_devlink for all GPIO dependencies.
 
Yes, your are correct, thanks!

Regards,
Li
  

Patch

diff --git a/drivers/of/property.c b/drivers/of/property.c
index ddc75cd50825..261eb8f3be08 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1272,7 +1272,7 @@  DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")
 static struct device_node *parse_gpios(struct device_node *np,
 				       const char *prop_name, int index)
 {
-	if (!strcmp_suffix(prop_name, ",nr-gpios"))
+	if (strcmp_suffix(prop_name, ",nr-gpios"))
 		return NULL;
 
 	return parse_suffix_prop_cells(np, prop_name, index, "-gpios",