From 281d3ffba9be4861a8c4e2aa4807d0d4ff4c0464 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 23 Jun 2015 14:15:43 +0200 Subject: [PATCH] hw: free correct IRQ when closing IRQ session The ~Irq_session_component relied on the IRQ number obtained by the corresponding kernel IRQ object to mark the IRQ as free at the IRQ allocator. However, since the kernel IRQ object is initialized not before the 'sigh' function is called, the IRQ of sessions that never called 'sigh' could not be freed correctly. This patch fixes the problem by not relying on the kernel IRQ object for obtaining the number in the destructor but using the '_irq_number' member variable instead. --- repos/base-hw/src/core/irq_session_component.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/repos/base-hw/src/core/irq_session_component.cc b/repos/base-hw/src/core/irq_session_component.cc index acfe29d2f0..4ac737b0d2 100644 --- a/repos/base-hw/src/core/irq_session_component.cc +++ b/repos/base-hw/src/core/irq_session_component.cc @@ -57,7 +57,7 @@ Irq_session_component::~Irq_session_component() using namespace Kernel; User_irq * kirq = reinterpret_cast(&_kernel_object); - _irq_alloc->free((void *)(addr_t)static_cast(kirq)->irq_number()); + _irq_alloc->free((void *)_irq_number); if (_sig_cap.valid()) Kernel::delete_irq(kirq); } @@ -66,8 +66,7 @@ Irq_session_component::~Irq_session_component() Irq_session_component::Irq_session_component(Range_allocator * const irq_alloc, const char * const args) : - _irq_number(Platform::irq(_find_irq_number(args))), - _irq_alloc(irq_alloc) + _irq_number(Platform::irq(_find_irq_number(args))), _irq_alloc(irq_alloc) { long const msi = Arg_string::find_arg(args, "device_config_phys").long_value(0); if (msi) @@ -75,7 +74,7 @@ Irq_session_component::Irq_session_component(Range_allocator * const irq_alloc, /* allocate interrupt */ if (_irq_alloc->alloc_addr(1, _irq_number).is_error()) { - PERR("unavailable interrupt requested"); + PERR("unavailable interrupt %d requested", _irq_number); throw Root::Invalid_args(); }