x86/irq: Fix maybe uninitalised issue in map_domain_pirq()
RFC PATCH 1/1 x86/irq: Fix maybe uninitalised issue in map_domain_pirq()
When compiling at -O3, GCC 7.2 reports:
irq.c: In function 'map_domain_pirq':
irq.c:1271:20: error: 'info' may be used uninitialized in this function [-Werror=maybe-uninitialized]
pirq->arch.irq = irq;
~~~~~~~~~~~~~~~^~~~~
irq.c:1917:18: note: 'info' was declared here
struct pirq *info;
^~~~This is a real issue, and is caused by different error style confusion in prepare_domain_irq_pirq(). A positive return value from radix_tree_insert() will take the early error path, and report success to map_domain_pirq().
---
CC: Jan Beulich <[email protected]>
I don't think this is the right change to make, but initialising note to NULL is definitely the wrong thing to do. Thoughts?
--- xen/arch/x86/irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/irq.c +1 -1
@@ -1249,7 +1249,7 @@ static int prepare_domain_irq_pirq(struct domain *d, int irq, int pirq, radix_tree_int_to_ptr(0));struct pirq *info; -if ( err && err != -EEXIST ) +if ( err <0 && err != -EEXIST )return err; info =pirq_get_info (d, pirq);if ( !info )
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 25.01.18 at 20:14, <[email protected]> wrote:
When compiling at -O3, GCC 7.2 reports:
irq.c: In function 'map_domain_pirq':
irq.c:1271:20: error: 'info' may be used uninitialized in this function
[-Werror=maybe-uninitialized]pirq->arch.irq = irq; ~~~~~~~~~~~~~~~^~~~~ irq.c:1917:18: note: 'info' was declared here struct pirq *info; ^~~~This is a real issue, and is caused by different error style confusion in
prepare_domain_irq_pirq(). A positive return value fromradix_tree_insert()will take the early error path, and report success tomap_domain_pirq().
Quoted 6 lines
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>I don't think this is the right change to make, but initialising note to NULL is definitely the wrong thing to do. Thoughts?
What I'd first of all like to understand - what about the two other call sites? They look like the same issue should arise there. init_domain_irq_mapping() has ASSERT(err < 0) - does that prevent it (I don't think it should)?
Assuming you mean "info" instead of "note", I agree that setting the pointer to NULL (or actually any pointer that shouldn't be de-referenced) would be wrong. However, I'm struggling to see why you say "this is a real issue": radix_tree_insert() won't ever return a positive value; it's just that the compiler can't know that. Perhaps an option would be to (pointlessly) convert a theoretical positive value there into some absurd -E...?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel