Skip to content
Snippets Groups Projects
Commit d7b48b8c authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Yang Yingliang
Browse files

genirq/matrix: Prevent allocation counter corruption

stable inclusion
from linux-4.19.191
commit 873792c84237953385d99ff3c56ed9e467c15300

--------------------------------

[ Upstream commit c93a5e20c3c2dabef8ea360a3d3f18c6f68233ab ]

When irq_matrix_free() is called for an unallocated vector the
managed_allocated and total_allocated counters get out of sync with the
real state of the matrix. Later, when the last interrupt is freed, these
counters will underflow resulting in UINTMAX because the counters are
unsigned.

While this is certainly a problem of the calling code, this can be catched
in the allocator by checking the allocation bit for the to be freed vector
which simplifies debugging.

An example of the problem described above:
https://lore.kernel.org/lkml/20210318192819.636943062@linutronix.de/



Add the missing sanity check and emit a warning when it triggers.

Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Thomas Gleixner <...
parent 6bbf4a5a
No related branches found
No related tags found
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment