mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-12 12:25:18 +02:00
um: Add winch to winch_handlers before registering winch IRQ
[ Upstream commita0fbbd36c1
] Registering a winch IRQ is racy, an interrupt may occur before the winch is added to the winch_handlers list. If that happens, register_winch_irq() adds to that list a winch that is scheduled to be (or has already been) freed, causing a panic later in winch_cleanup(). Avoid the race by adding the winch to the winch_handlers list before registering the IRQ, and rolling back if um_request_irq() fails. Fixes:42a359e31a
("uml: SIGIO support cleanup") Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Reviewed-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e98f29bf0b
commit
434a06c38e
|
@ -673,24 +673,26 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_port *port,
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
*winch = ((struct winch) { .list = LIST_HEAD_INIT(winch->list),
|
*winch = ((struct winch) { .fd = fd,
|
||||||
.fd = fd,
|
|
||||||
.tty_fd = tty_fd,
|
.tty_fd = tty_fd,
|
||||||
.pid = pid,
|
.pid = pid,
|
||||||
.port = port,
|
.port = port,
|
||||||
.stack = stack });
|
.stack = stack });
|
||||||
|
|
||||||
|
spin_lock(&winch_handler_lock);
|
||||||
|
list_add(&winch->list, &winch_handlers);
|
||||||
|
spin_unlock(&winch_handler_lock);
|
||||||
|
|
||||||
if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
|
if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
|
||||||
IRQF_SHARED, "winch", winch) < 0) {
|
IRQF_SHARED, "winch", winch) < 0) {
|
||||||
printk(KERN_ERR "register_winch_irq - failed to register "
|
printk(KERN_ERR "register_winch_irq - failed to register "
|
||||||
"IRQ\n");
|
"IRQ\n");
|
||||||
|
spin_lock(&winch_handler_lock);
|
||||||
|
list_del(&winch->list);
|
||||||
|
spin_unlock(&winch_handler_lock);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock(&winch_handler_lock);
|
|
||||||
list_add(&winch->list, &winch_handlers);
|
|
||||||
spin_unlock(&winch_handler_lock);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
out_free:
|
out_free:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user