Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
9a2225f2 b339809e

+11 -9
+11 -9
drivers/tty/serial/8250/8250_core.c
··· 178 178 { 179 179 struct irq_info *i; 180 180 181 - mutex_lock(&hash_mutex); 181 + guard(mutex)(&hash_mutex); 182 182 183 183 hash_for_each_possible(irq_lists, i, node, up->port.irq) 184 - if (i->irq == up->port.irq) 185 - break; 184 + if (i->irq == up->port.irq) { 185 + if (WARN_ON(i->head == NULL)) 186 + return; 186 187 187 - BUG_ON(i == NULL); 188 - BUG_ON(i->head == NULL); 188 + if (list_empty(i->head)) 189 + free_irq(up->port.irq, i); 189 190 190 - if (list_empty(i->head)) 191 - free_irq(up->port.irq, i); 191 + serial_do_unlink(i, up); 192 192 193 - serial_do_unlink(i, up); 194 - mutex_unlock(&hash_mutex); 193 + return; 194 + } 195 + 196 + WARN_ON(1); 195 197 } 196 198 197 199 /*