[PATCH v2] xen/irq: Propagate the error from init_one_desc_irq() in init_*_irq_data()

Julien Grall posted 1 patch 3 years, 4 months ago
Test gitlab-ci passed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20201128113642.8265-1-julien@xen.org
xen/arch/arm/irq.c | 12 ++++++++++--
xen/arch/x86/irq.c |  7 ++++++-
2 files changed, 16 insertions(+), 3 deletions(-)
[PATCH v2] xen/irq: Propagate the error from init_one_desc_irq() in init_*_irq_data()
Posted by Julien Grall 3 years, 4 months ago
From: Julien Grall <jgrall@amazon.com>

init_one_desc_irq() can return an error if it is unable to allocate
memory. While this is unlikely to happen during boot (called from
init_{,local_}irq_data()), it is better to harden the code by
propagting the return value.

Spotted by coverity.

CID: 106529

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Roger Paul Monné <roger.pau@citrix.com>

---
    Changes in v2:
        - Add Roger's reviewed-by for x86
        - Handle
---
 xen/arch/arm/irq.c | 12 ++++++++++--
 xen/arch/x86/irq.c |  7 ++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 3877657a5277..b71b099e6fa2 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -88,7 +88,11 @@ static int __init init_irq_data(void)
     for ( irq = NR_LOCAL_IRQS; irq < NR_IRQS; irq++ )
     {
         struct irq_desc *desc = irq_to_desc(irq);
-        init_one_irq_desc(desc);
+        int rc = init_one_irq_desc(desc);
+
+        if ( rc )
+            return rc;
+
         desc->irq = irq;
         desc->action  = NULL;
     }
@@ -105,7 +109,11 @@ static int init_local_irq_data(void)
     for ( irq = 0; irq < NR_LOCAL_IRQS; irq++ )
     {
         struct irq_desc *desc = irq_to_desc(irq);
-        init_one_irq_desc(desc);
+        int rc = init_one_irq_desc(desc);
+
+        if ( rc )
+            return rc;
+
         desc->irq = irq;
         desc->action  = NULL;
 
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 45966947919e..3ebd684415ac 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -428,9 +428,14 @@ int __init init_irq_data(void)
 
     for ( irq = 0; irq < nr_irqs_gsi; irq++ )
     {
+        int rc;
+
         desc = irq_to_desc(irq);
         desc->irq = irq;
-        init_one_irq_desc(desc);
+
+        rc = init_one_irq_desc(desc);
+        if ( rc )
+            return rc;
     }
     for ( ; irq < nr_irqs; irq++ )
         irq_to_desc(irq)->irq = irq;
-- 
2.17.1


Re: [PATCH v2] xen/irq: Propagate the error from init_one_desc_irq() in init_*_irq_data()
Posted by Volodymyr Babchuk 3 years, 4 months ago
Hi Julien,

Julien Grall writes:

> From: Julien Grall <jgrall@amazon.com>
>
> init_one_desc_irq() can return an error if it is unable to allocate
> memory. While this is unlikely to happen during boot (called from
> init_{,local_}irq_data()), it is better to harden the code by
> propagting the return value.
>
> Spotted by coverity.
>
> CID: 106529
>
> Signed-off-by: Julien Grall <jgrall@amazon.com>
> Reviewed-by: Roger Paul Monné <roger.pau@citrix.com>

Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

For ARM part, obviously.

>
> ---
>     Changes in v2:
>         - Add Roger's reviewed-by for x86
>         - Handle
> ---
>  xen/arch/arm/irq.c | 12 ++++++++++--
>  xen/arch/x86/irq.c |  7 ++++++-
>  2 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index 3877657a5277..b71b099e6fa2 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -88,7 +88,11 @@ static int __init init_irq_data(void)
>      for ( irq = NR_LOCAL_IRQS; irq < NR_IRQS; irq++ )
>      {
>          struct irq_desc *desc = irq_to_desc(irq);
> -        init_one_irq_desc(desc);
> +        int rc = init_one_irq_desc(desc);
> +
> +        if ( rc )
> +            return rc;
> +
>          desc->irq = irq;
>          desc->action  = NULL;
>      }
> @@ -105,7 +109,11 @@ static int init_local_irq_data(void)
>      for ( irq = 0; irq < NR_LOCAL_IRQS; irq++ )
>      {
>          struct irq_desc *desc = irq_to_desc(irq);
> -        init_one_irq_desc(desc);
> +        int rc = init_one_irq_desc(desc);
> +
> +        if ( rc )
> +            return rc;
> +
>          desc->irq = irq;
>          desc->action  = NULL;
>  
> diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
> index 45966947919e..3ebd684415ac 100644
> --- a/xen/arch/x86/irq.c
> +++ b/xen/arch/x86/irq.c
> @@ -428,9 +428,14 @@ int __init init_irq_data(void)
>  
>      for ( irq = 0; irq < nr_irqs_gsi; irq++ )
>      {
> +        int rc;
> +
>          desc = irq_to_desc(irq);
>          desc->irq = irq;
> -        init_one_irq_desc(desc);
> +
> +        rc = init_one_irq_desc(desc);
> +        if ( rc )
> +            return rc;
>      }
>      for ( ; irq < nr_irqs; irq++ )
>          irq_to_desc(irq)->irq = irq;


-- 
Volodymyr Babchuk at EPAM
[PING] Re: [PATCH v2] xen/irq: Propagate the error from init_one_desc_irq() in init_*_irq_data()
Posted by Julien Grall 3 years, 3 months ago
Hi all,

On 28/11/2020 11:36, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
> 
> init_one_desc_irq() can return an error if it is unable to allocate
> memory. While this is unlikely to happen during boot (called from
> init_{,local_}irq_data()), it is better to harden the code by
> propagting the return value.
> 
> Spotted by coverity.
> 
> CID: 106529
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>
> Reviewed-by: Roger Paul Monné <roger.pau@citrix.com>

 From my understanding of MAINTAINERS rule, I still need an ack from x86 
maintainers.

Cheers,

-- 
Julien Grall

Re: [PING] Re: [PATCH v2] xen/irq: Propagate the error from init_one_desc_irq() in init_*_irq_data()
Posted by Jan Beulich 3 years, 3 months ago
On 13.01.2021 20:05, Julien Grall wrote:
> On 28/11/2020 11:36, Julien Grall wrote:
>> From: Julien Grall <jgrall@amazon.com>
>>
>> init_one_desc_irq() can return an error if it is unable to allocate
>> memory. While this is unlikely to happen during boot (called from
>> init_{,local_}irq_data()), it is better to harden the code by
>> propagting the return value.
>>
>> Spotted by coverity.
>>
>> CID: 106529
>>
>> Signed-off-by: Julien Grall <jgrall@amazon.com>
>> Reviewed-by: Roger Paul Monné <roger.pau@citrix.com>
> 
>  From my understanding of MAINTAINERS rule, I still need an ack from x86 
> maintainers.

Roger _is_ an x86 maintainer, so why would you need another ack?

Jan

Re: [PING] Re: [PATCH v2] xen/irq: Propagate the error from init_one_desc_irq() in init_*_irq_data()
Posted by Julien Grall 3 years, 3 months ago

On 14/01/2021 09:15, Jan Beulich wrote:
> On 13.01.2021 20:05, Julien Grall wrote:
>> On 28/11/2020 11:36, Julien Grall wrote:
>>> From: Julien Grall <jgrall@amazon.com>
>>>
>>> init_one_desc_irq() can return an error if it is unable to allocate
>>> memory. While this is unlikely to happen during boot (called from
>>> init_{,local_}irq_data()), it is better to harden the code by
>>> propagting the return value.
>>>
>>> Spotted by coverity.
>>>
>>> CID: 106529
>>>
>>> Signed-off-by: Julien Grall <jgrall@amazon.com>
>>> Reviewed-by: Roger Paul Monné <roger.pau@citrix.com>
>>
>>   From my understanding of MAINTAINERS rule, I still need an ack from x86
>> maintainers.
> 
> Roger _is_ an x86 maintainer, so why would you need another ack?

Because I didn't realize that Roger became an x86 Maintainer...

I will commit the patch then.

Cheers,

-- 
Julien Grall

Re: [PATCH v2] xen/irq: Propagate the error from init_one_desc_irq() in init_*_irq_data()
Posted by Bertrand Marquis 3 years, 4 months ago

> On 28 Nov 2020, at 11:36, Julien Grall <julien@xen.org> wrote:
> 
> From: Julien Grall <jgrall@amazon.com>
> 
> init_one_desc_irq() can return an error if it is unable to allocate
> memory. While this is unlikely to happen during boot (called from
> init_{,local_}irq_data()), it is better to harden the code by
> propagting the return value.
> 
> Spotted by coverity.
> 
> CID: 106529
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>
> Reviewed-by: Roger Paul Monné <roger.pau@citrix.com>

Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> 
> ---
>    Changes in v2:
>        - Add Roger's reviewed-by for x86
>        - Handle
> ---
> xen/arch/arm/irq.c | 12 ++++++++++--
> xen/arch/x86/irq.c |  7 ++++++-
> 2 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index 3877657a5277..b71b099e6fa2 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -88,7 +88,11 @@ static int __init init_irq_data(void)
>     for ( irq = NR_LOCAL_IRQS; irq < NR_IRQS; irq++ )
>     {
>         struct irq_desc *desc = irq_to_desc(irq);
> -        init_one_irq_desc(desc);
> +        int rc = init_one_irq_desc(desc);
> +
> +        if ( rc )
> +            return rc;
> +
>         desc->irq = irq;
>         desc->action  = NULL;
>     }
> @@ -105,7 +109,11 @@ static int init_local_irq_data(void)
>     for ( irq = 0; irq < NR_LOCAL_IRQS; irq++ )
>     {
>         struct irq_desc *desc = irq_to_desc(irq);
> -        init_one_irq_desc(desc);
> +        int rc = init_one_irq_desc(desc);
> +
> +        if ( rc )
> +            return rc;
> +
>         desc->irq = irq;
>         desc->action  = NULL;
> 
> diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
> index 45966947919e..3ebd684415ac 100644
> --- a/xen/arch/x86/irq.c
> +++ b/xen/arch/x86/irq.c
> @@ -428,9 +428,14 @@ int __init init_irq_data(void)
> 
>     for ( irq = 0; irq < nr_irqs_gsi; irq++ )
>     {
> +        int rc;
> +
>         desc = irq_to_desc(irq);
>         desc->irq = irq;
> -        init_one_irq_desc(desc);
> +
> +        rc = init_one_irq_desc(desc);
> +        if ( rc )
> +            return rc;
>     }
>     for ( ; irq < nr_irqs; irq++ )
>         irq_to_desc(irq)->irq = irq;
> -- 
> 2.17.1
> 
> 

Re: [PATCH v2] xen/irq: Propagate the error from init_one_desc_irq() in init_*_irq_data()
Posted by Stefano Stabellini 3 years, 4 months ago
On Wed, 2 Dec 2020, Bertrand Marquis wrote:
> > On 28 Nov 2020, at 11:36, Julien Grall <julien@xen.org> wrote:
> > 
> > From: Julien Grall <jgrall@amazon.com>
> > 
> > init_one_desc_irq() can return an error if it is unable to allocate
> > memory. While this is unlikely to happen during boot (called from
> > init_{,local_}irq_data()), it is better to harden the code by
> > propagting the return value.
> > 
> > Spotted by coverity.
> > 
> > CID: 106529
> > 
> > Signed-off-by: Julien Grall <jgrall@amazon.com>
> > Reviewed-by: Roger Paul Monné <roger.pau@citrix.com>
> 
> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>


> > ---
> >    Changes in v2:
> >        - Add Roger's reviewed-by for x86
> >        - Handle
> > ---
> > xen/arch/arm/irq.c | 12 ++++++++++--
> > xen/arch/x86/irq.c |  7 ++++++-
> > 2 files changed, 16 insertions(+), 3 deletions(-)
> > 
> > diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> > index 3877657a5277..b71b099e6fa2 100644
> > --- a/xen/arch/arm/irq.c
> > +++ b/xen/arch/arm/irq.c
> > @@ -88,7 +88,11 @@ static int __init init_irq_data(void)
> >     for ( irq = NR_LOCAL_IRQS; irq < NR_IRQS; irq++ )
> >     {
> >         struct irq_desc *desc = irq_to_desc(irq);
> > -        init_one_irq_desc(desc);
> > +        int rc = init_one_irq_desc(desc);
> > +
> > +        if ( rc )
> > +            return rc;
> > +
> >         desc->irq = irq;
> >         desc->action  = NULL;
> >     }
> > @@ -105,7 +109,11 @@ static int init_local_irq_data(void)
> >     for ( irq = 0; irq < NR_LOCAL_IRQS; irq++ )
> >     {
> >         struct irq_desc *desc = irq_to_desc(irq);
> > -        init_one_irq_desc(desc);
> > +        int rc = init_one_irq_desc(desc);
> > +
> > +        if ( rc )
> > +            return rc;
> > +
> >         desc->irq = irq;
> >         desc->action  = NULL;
> > 
> > diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
> > index 45966947919e..3ebd684415ac 100644
> > --- a/xen/arch/x86/irq.c
> > +++ b/xen/arch/x86/irq.c
> > @@ -428,9 +428,14 @@ int __init init_irq_data(void)
> > 
> >     for ( irq = 0; irq < nr_irqs_gsi; irq++ )
> >     {
> > +        int rc;
> > +
> >         desc = irq_to_desc(irq);
> >         desc->irq = irq;
> > -        init_one_irq_desc(desc);
> > +
> > +        rc = init_one_irq_desc(desc);
> > +        if ( rc )
> > +            return rc;
> >     }
> >     for ( ; irq < nr_irqs; irq++ )
> >         irq_to_desc(irq)->irq = irq;
> > -- 
> > 2.17.1
> > 
> > 
> 
>