summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby (SUSE) <jirislaby@kernel.org>2025-08-14 09:24:50 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-17 12:46:26 +0200
commit9a2225f2a7214cc04a03a09768b19215a3fe4c16 (patch)
tree40342d21d8d8cedcf068c9c867f0becaacfd6531
parentb339809edda15939e7d46b429c420c2bfe4ad946 (diff)
serial: 8250_core: use guard() in serial_unlink_irq_chain()
Having all the new guards, use them in the 8250 code. This improves readability, makes error handling easier, and marks locked portions of code explicit. serial_unlink_irq_chain() is done separately here because with the guard() used, those BUG_ON()s can be switched WARN_ON()s as we can actually handle the conditions and return (despite something went really wrong). Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20250814072456.182853-11-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/8250/8250_core.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 82c3636451e5..7d931693b311 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -178,20 +178,22 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up)
{
struct irq_info *i;
- mutex_lock(&hash_mutex);
+ guard(mutex)(&hash_mutex);
hash_for_each_possible(irq_lists, i, node, up->port.irq)
- if (i->irq == up->port.irq)
- break;
+ if (i->irq == up->port.irq) {
+ if (WARN_ON(i->head == NULL))
+ return;
- BUG_ON(i == NULL);
- BUG_ON(i->head == NULL);
+ if (list_empty(i->head))
+ free_irq(up->port.irq, i);
- if (list_empty(i->head))
- free_irq(up->port.irq, i);
+ serial_do_unlink(i, up);
+
+ return;
+ }
- serial_do_unlink(i, up);
- mutex_unlock(&hash_mutex);
+ WARN_ON(1);
}
/*