All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip/loongson-liointc: Fix an error handling path in liointc_init()
@ 2022-05-22 13:44 Christophe JAILLET
  2022-05-24  2:50 ` Huacai Chen
  0 siblings, 1 reply; 7+ messages in thread
From: Christophe JAILLET @ 2022-05-22 13:44 UTC (permalink / raw)
  To: dan.carpenter, Huacai Chen, Jiaxun Yang, Thomas Gleixner, Marc Zyngier
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-mips

If a of_property_match_string() call fails, we still need to release some
resources.
Add the corresponding goto instead of a direct return.

Fixes: 807e93d0ecbb ("irqchip/loongson-liointc: Add ACPI init support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/irqchip/irq-loongson-liointc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
index ff3cb5b05710..2227b702a81d 100644
--- a/drivers/irqchip/irq-loongson-liointc.c
+++ b/drivers/irqchip/irq-loongson-liointc.c
@@ -185,8 +185,10 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision,
 			int index = of_property_match_string(node,
 					"reg-names", core_reg_names[i]);
 
-			if (index < 0)
-				return -EINVAL;
+			if (index < 0) {
+				err = -EINVAL;
+				goto out_iounmap;
+			}
 
 			priv->core_isr[i] = of_iomap(node, index);
 		}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] irqchip/loongson-liointc: Fix an error handling path in liointc_init()
  2022-05-22 13:44 [PATCH] irqchip/loongson-liointc: Fix an error handling path in liointc_init() Christophe JAILLET
@ 2022-05-24  2:50 ` Huacai Chen
  2022-05-24  3:47   ` Huacai Chen
  0 siblings, 1 reply; 7+ messages in thread
From: Huacai Chen @ 2022-05-24  2:50 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: dan.carpenter, Jiaxun Yang, Thomas Gleixner, Marc Zyngier, LKML,
	kernel-janitors, open list:MIPS

Hi, Christophe,

On Sun, May 22, 2022 at 9:44 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> If a of_property_match_string() call fails, we still need to release some
> resources.
> Add the corresponding goto instead of a direct return.
Your patch is correct, but 807e93d0ecbb hasn't been upstream, I don't
know how to handle it.

Huacai
>
> Fixes: 807e93d0ecbb ("irqchip/loongson-liointc: Add ACPI init support")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/irqchip/irq-loongson-liointc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
> index ff3cb5b05710..2227b702a81d 100644
> --- a/drivers/irqchip/irq-loongson-liointc.c
> +++ b/drivers/irqchip/irq-loongson-liointc.c
> @@ -185,8 +185,10 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision,
>                         int index = of_property_match_string(node,
>                                         "reg-names", core_reg_names[i]);
>
> -                       if (index < 0)
> -                               return -EINVAL;
> +                       if (index < 0) {
> +                               err = -EINVAL;
> +                               goto out_iounmap;
> +                       }
>
>                         priv->core_isr[i] = of_iomap(node, index);
>                 }
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] irqchip/loongson-liointc: Fix an error handling path in liointc_init()
  2022-05-24  2:50 ` Huacai Chen
@ 2022-05-24  3:47   ` Huacai Chen
  2022-05-24  5:36     ` Christophe JAILLET
  2022-05-24  5:41     ` WANG Xuerui
  0 siblings, 2 replies; 7+ messages in thread
From: Huacai Chen @ 2022-05-24  3:47 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: dan.carpenter, Jiaxun Yang, Thomas Gleixner, Marc Zyngier, LKML,
	kernel-janitors, open list:MIPS

Hi, Christophe,

On Tue, May 24, 2022 at 10:50 AM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> Hi, Christophe,
>
> On Sun, May 22, 2022 at 9:44 PM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
> >
> > If a of_property_match_string() call fails, we still need to release some
> > resources.
> > Add the corresponding goto instead of a direct return.
> Your patch is correct, but 807e93d0ecbb hasn't been upstream, I don't
> know how to handle it.
>
> Huacai
> >
> > Fixes: 807e93d0ecbb ("irqchip/loongson-liointc: Add ACPI init support")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> >  drivers/irqchip/irq-loongson-liointc.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
> > index ff3cb5b05710..2227b702a81d 100644
> > --- a/drivers/irqchip/irq-loongson-liointc.c
> > +++ b/drivers/irqchip/irq-loongson-liointc.c
> > @@ -185,8 +185,10 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision,
> >                         int index = of_property_match_string(node,
> >                                         "reg-names", core_reg_names[i]);
> >
> > -                       if (index < 0)
> > -                               return -EINVAL;
> > +                       if (index < 0) {
> > +                               err = -EINVAL;
> > +                               goto out_iounmap;
> > +                       }
Just goto out_iounmap is OK, because it returns -EINVAL at last.
I've squash your patch to the original one and add a Co-developed-by:,
not sure it is the best solution. Thanks.

Huacai
> >
> >                         priv->core_isr[i] = of_iomap(node, index);
> >                 }
> > --
> > 2.34.1
> >

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] irqchip/loongson-liointc: Fix an error handling path in liointc_init()
  2022-05-24  3:47   ` Huacai Chen
@ 2022-05-24  5:36     ` Christophe JAILLET
  2022-05-24  5:41     ` WANG Xuerui
  1 sibling, 0 replies; 7+ messages in thread
From: Christophe JAILLET @ 2022-05-24  5:36 UTC (permalink / raw)
  To: Huacai Chen
  Cc: dan.carpenter, Jiaxun Yang, Thomas Gleixner, Marc Zyngier, LKML,
	kernel-janitors, open list:MIPS

Le 24/05/2022 à 05:47, Huacai Chen a écrit :
> Hi, Christophe,
> 
> On Tue, May 24, 2022 at 10:50 AM Huacai Chen <chenhuacai@kernel.org> wrote:
>>
>> Hi, Christophe,
>>
>> On Sun, May 22, 2022 at 9:44 PM Christophe JAILLET
>> <christophe.jaillet@wanadoo.fr> wrote:
>>>
>>> If a of_property_match_string() call fails, we still need to release some
>>> resources.
>>> Add the corresponding goto instead of a direct return.
>> Your patch is correct, but 807e93d0ecbb hasn't been upstream, I don't
>> know how to handle it.
>>
>> Huacai
>>>
>>> Fixes: 807e93d0ecbb ("irqchip/loongson-liointc: Add ACPI init support")
>>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> ---
>>>   drivers/irqchip/irq-loongson-liointc.c | 6 ++++--
>>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
>>> index ff3cb5b05710..2227b702a81d 100644
>>> --- a/drivers/irqchip/irq-loongson-liointc.c
>>> +++ b/drivers/irqchip/irq-loongson-liointc.c
>>> @@ -185,8 +185,10 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision,
>>>                          int index = of_property_match_string(node,
>>>                                          "reg-names", core_reg_names[i]);
>>>
>>> -                       if (index < 0)
>>> -                               return -EINVAL;
>>> +                       if (index < 0) {
>>> +                               err = -EINVAL;
>>> +                               goto out_iounmap;
>>> +                       }
> Just goto out_iounmap is OK, because it returns -EINVAL at last.

Yes, agreed.

> I've squash your patch to the original one and add a Co-developed-by:,
> not sure it is the best solution. Thanks.

Squashing in the original patch is fine for me. It is what is usually 
done in such cases.

The Co-developed-by: is maybe a bit to much. I've just fixed a bug that 
can't happen (IMHO) in real life. I'll let you decide what is more relevant.
With or without the tag is fine for me as well.

CJ


> 
> Huacai
>>>
>>>                          priv->core_isr[i] = of_iomap(node, index);
>>>                  }
>>> --
>>> 2.34.1
>>>
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] irqchip/loongson-liointc: Fix an error handling path in liointc_init()
  2022-05-24  3:47   ` Huacai Chen
  2022-05-24  5:36     ` Christophe JAILLET
@ 2022-05-24  5:41     ` WANG Xuerui
  2022-05-24 10:48       ` Huacai Chen
  1 sibling, 1 reply; 7+ messages in thread
From: WANG Xuerui @ 2022-05-24  5:41 UTC (permalink / raw)
  To: Huacai Chen, Christophe JAILLET
  Cc: dan.carpenter, Jiaxun Yang, Thomas Gleixner, Marc Zyngier, LKML,
	kernel-janitors, open list:MIPS

Hi Huacai,

On 5/24/22 11:47, Huacai Chen wrote:
> Hi, Christophe,
>
> On Tue, May 24, 2022 at 10:50 AM Huacai Chen <chenhuacai@kernel.org> wrote:
>> Hi, Christophe,
>>
>> On Sun, May 22, 2022 at 9:44 PM Christophe JAILLET
>> <christophe.jaillet@wanadoo.fr> wrote:
>>> If a of_property_match_string() call fails, we still need to release some
>>> resources.
>>> Add the corresponding goto instead of a direct return.
>> Your patch is correct, but 807e93d0ecbb hasn't been upstream, I don't
>> know how to handle it.
>>
>> Huacai
>>> Fixes: 807e93d0ecbb ("irqchip/loongson-liointc: Add ACPI init support")
>>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> ---
>>>   drivers/irqchip/irq-loongson-liointc.c | 6 ++++--
>>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
>>> index ff3cb5b05710..2227b702a81d 100644
>>> --- a/drivers/irqchip/irq-loongson-liointc.c
>>> +++ b/drivers/irqchip/irq-loongson-liointc.c
>>> @@ -185,8 +185,10 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision,
>>>                          int index = of_property_match_string(node,
>>>                                          "reg-names", core_reg_names[i]);
>>>
>>> -                       if (index < 0)
>>> -                               return -EINVAL;
>>> +                       if (index < 0) {
>>> +                               err = -EINVAL;
>>> +                               goto out_iounmap;
>>> +                       }
> Just goto out_iounmap is OK, because it returns -EINVAL at last.
> I've squash your patch to the original one and add a Co-developed-by:,
> not sure it is the best solution. Thanks.
You could also "Reported-by" and/or "Suggested-by", to give proper 
credit. Mention of this mail thread (link to lore.kernel.org archive 
maybe) in the commit message is good too.
>
> Huacai
>>>                          priv->core_isr[i] = of_iomap(node, index);
>>>                  }
>>> --
>>> 2.34.1
>>>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] irqchip/loongson-liointc: Fix an error handling path in liointc_init()
  2022-05-24  5:41     ` WANG Xuerui
@ 2022-05-24 10:48       ` Huacai Chen
  0 siblings, 0 replies; 7+ messages in thread
From: Huacai Chen @ 2022-05-24 10:48 UTC (permalink / raw)
  To: WANG Xuerui
  Cc: Christophe JAILLET, dan.carpenter, Jiaxun Yang, Thomas Gleixner,
	Marc Zyngier, LKML, kernel-janitors, open list:MIPS

Hi, Xuerui,

On Tue, May 24, 2022 at 1:41 PM WANG Xuerui <kernel@xen0n.name> wrote:
>
> Hi Huacai,
>
> On 5/24/22 11:47, Huacai Chen wrote:
> > Hi, Christophe,
> >
> > On Tue, May 24, 2022 at 10:50 AM Huacai Chen <chenhuacai@kernel.org> wrote:
> >> Hi, Christophe,
> >>
> >> On Sun, May 22, 2022 at 9:44 PM Christophe JAILLET
> >> <christophe.jaillet@wanadoo.fr> wrote:
> >>> If a of_property_match_string() call fails, we still need to release some
> >>> resources.
> >>> Add the corresponding goto instead of a direct return.
> >> Your patch is correct, but 807e93d0ecbb hasn't been upstream, I don't
> >> know how to handle it.
> >>
> >> Huacai
> >>> Fixes: 807e93d0ecbb ("irqchip/loongson-liointc: Add ACPI init support")
> >>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >>> ---
> >>>   drivers/irqchip/irq-loongson-liointc.c | 6 ++++--
> >>>   1 file changed, 4 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
> >>> index ff3cb5b05710..2227b702a81d 100644
> >>> --- a/drivers/irqchip/irq-loongson-liointc.c
> >>> +++ b/drivers/irqchip/irq-loongson-liointc.c
> >>> @@ -185,8 +185,10 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision,
> >>>                          int index = of_property_match_string(node,
> >>>                                          "reg-names", core_reg_names[i]);
> >>>
> >>> -                       if (index < 0)
> >>> -                               return -EINVAL;
> >>> +                       if (index < 0) {
> >>> +                               err = -EINVAL;
> >>> +                               goto out_iounmap;
> >>> +                       }
> > Just goto out_iounmap is OK, because it returns -EINVAL at last.
> > I've squash your patch to the original one and add a Co-developed-by:,
> > not sure it is the best solution. Thanks.
> You could also "Reported-by" and/or "Suggested-by", to give proper
> credit. Mention of this mail thread (link to lore.kernel.org archive
> maybe) in the commit message is good too.
I think "Reported-by" is used for a bugfix patch, not suitable for the
original patch. And maybe "Suggested-by" is the best.

Huacai
> >
> > Huacai
> >>>                          priv->core_isr[i] = of_iomap(node, index);
> >>>                  }
> >>> --
> >>> 2.34.1
> >>>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] irqchip/loongson-liointc: Fix an error handling path in liointc_init()
@ 2022-08-01 19:28 Christophe JAILLET
  0 siblings, 0 replies; 7+ messages in thread
From: Christophe JAILLET @ 2022-08-01 19:28 UTC (permalink / raw)
  To: Huacai Chen, Jiaxun Yang, Thomas Gleixner, Marc Zyngier, Jianmin Lv
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-mips

All errors lead to the error handling path, except this one.
Fix it and release some resources before returning if this test fails.

Fixes: 0858ed035a85 ("irqchip/loongson-liointc: Add ACPI init support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/irqchip/irq-loongson-liointc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
index c4f3c886ad61..8ab59b658913 100644
--- a/drivers/irqchip/irq-loongson-liointc.c
+++ b/drivers/irqchip/irq-loongson-liointc.c
@@ -207,7 +207,7 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision,
 					"reg-names", core_reg_names[i]);
 
 			if (index < 0)
-				return -EINVAL;
+				goto out_iounmap;
 
 			priv->core_isr[i] = of_iomap(node, index);
 		}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-01 19:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-22 13:44 [PATCH] irqchip/loongson-liointc: Fix an error handling path in liointc_init() Christophe JAILLET
2022-05-24  2:50 ` Huacai Chen
2022-05-24  3:47   ` Huacai Chen
2022-05-24  5:36     ` Christophe JAILLET
2022-05-24  5:41     ` WANG Xuerui
2022-05-24 10:48       ` Huacai Chen
2022-08-01 19:28 Christophe JAILLET

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.