Skip to contentSkip to conversation

xen/irq: Propagate the error from init_one_desc_irq() in init_*_irq_data()

PATCH In review Julien Grall 5 participants 7 messages Nov 28, 2020 – Jan 14, 2021

lore
Share & tools
lore
#0 lore raw

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

From: Julien Grall <[email protected]>

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

---
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(-)
xen/arch/arm/irq.c +10 -2
index 3877657a5277..b71b099e6fa2 100644
@@ -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;
 
xen/arch/x86/irq.c +6 -1
index 45966947919e..3ebd684415ac 100644
@@ -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;
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw

Hi Julien,

Quoted 7 lines · Julien Grall

From: Julien Grall <[email protected]>

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.

Quoted 6 lines

Spotted by coverity.

CID: 106529

For ARM part, obviously.

Quoted 60 lines

---
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(-)
xen/arch/arm/irq.c +10 -2
index 3877657a5277..b71b099e6fa2 100644
@@ -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;
 
xen/arch/x86/irq.c +6 -1
index 45966947919e..3ebd684415ac 100644
@@ -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;
Signature · 1 line
Volodymyr Babchuk at EPAM
Reviewed-by on v2 1/1
#2 lore raw
In reply to Julien Grall
Quoted 11 lines · Julien Grall

From: Julien Grall <[email protected]>

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.

Quoted 6 lines

Spotted by coverity.

CID: 106529

Cheers
Bertrand

Quoted 64 lines

---
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(-)
xen/arch/arm/irq.c +10 -2
index 3877657a5277..b71b099e6fa2 100644
@@ -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;
 
xen/arch/x86/irq.c +6 -1
index 45966947919e..3ebd684415ac 100644
@@ -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;
Signature · 1 line
2.17.1
#3 lore raw
Quoted 9 lines · Bertrand Marquis
Quoted 9 lines · Julien Grall

From: Julien Grall <[email protected]>

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.

Quoted 8 lines
Quoted 6 lines

Spotted by coverity.

CID: 106529

Quoted 65 lines
Quoted 63 lines

---
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(-)
xen/arch/arm/irq.c +10 -2
index 3877657a5277..b71b099e6fa2 100644
@@ -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;
 
xen/arch/x86/irq.c +6 -1
index 45966947919e..3ebd684415ac 100644
@@ -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;
Signature · 1 line
2.17.1
#4 lore raw
In reply to Julien Grall

Hi all,

Quoted 7 lines · Julien Grall

From: Julien Grall <[email protected]>

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.

Quoted 6 lines

Spotted by coverity.

CID: 106529

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

Cheers,

Signature · 1 line
Julien Grall
#5 lore raw
Quoted 10 lines · Julien Grall
Quoted 9 lines · Julien Grall

From: Julien Grall <[email protected]>

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.

Quoted 7 lines
Quoted 4 lines

CID: 106529

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

#6 lore raw
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Julien Grall
Quoted 11 lines · Julien Grall

From: Julien Grall <[email protected]>

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

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

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,

Signature · 1 line
Julien Grall