Skip to content

Commit a2ea3cd

Browse files
andy-shevKAGA-KOKO
authored andcommitted
irqdomain: Check virq for 0 before use in irq_dispose_mapping()
It's a bit hard to read the logic since the virq is used before checking it for 0. Rearrange the code to make it better to understand. This, in particular, should clearly answer the question whether the caller needs to perform this check or not, and there are plenty of places for both variants, confirming a confusion. Fun fact that the new code is shorter: Function old new delta irq_dispose_mapping 278 271 -7 Total: Before=11625, After=11618, chg -0.06% when compiled by GCC on Debian for x86_64. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20240405190105.3932034-1-andriy.shevchenko@linux.intel.com
1 parent 7b6f0f2 commit a2ea3cd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

kernel/irq/irqdomain.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,11 @@ EXPORT_SYMBOL_GPL(irq_create_of_mapping);
909909
*/
910910
void irq_dispose_mapping(unsigned int virq)
911911
{
912-
struct irq_data *irq_data = irq_get_irq_data(virq);
912+
struct irq_data *irq_data;
913913
struct irq_domain *domain;
914914

915-
if (!virq || !irq_data)
915+
irq_data = virq ? irq_get_irq_data(virq) : NULL;
916+
if (!irq_data)
916917
return;
917918

918919
domain = irq_data->domain;

0 commit comments

Comments
 (0)