Skip to content

Commit 4327981

Browse files
Dan Carpentergregkh
authored andcommitted
uio: Fix an Oops on load
I was trying to solve a double free but I introduced a more serious NULL dereference bug. The problem is that if there is an IRQ which triggers immediately, then we need "info->uio_dev" but it's not set yet. This patch puts the original initialization back to how it was and just sets info->uio_dev to NULL on the error path so it should solve both the Oops and the double free. Fixes: f019f07 ("uio: potential double frees if __uio_register_device() fails") Reported-by: Mathias Thore <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Cc: stable <[email protected]> Tested-by: Mathias Thore <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8bb0a88 commit 4327981

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/uio/uio.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,8 @@ int __uio_register_device(struct module *owner,
961961
if (ret)
962962
goto err_uio_dev_add_attributes;
963963

964+
info->uio_dev = idev;
965+
964966
if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) {
965967
/*
966968
* Note that we deliberately don't use devm_request_irq
@@ -972,11 +974,12 @@ int __uio_register_device(struct module *owner,
972974
*/
973975
ret = request_irq(info->irq, uio_interrupt,
974976
info->irq_flags, info->name, idev);
975-
if (ret)
977+
if (ret) {
978+
info->uio_dev = NULL;
976979
goto err_request_irq;
980+
}
977981
}
978982

979-
info->uio_dev = idev;
980983
return 0;
981984

982985
err_request_irq:

0 commit comments

Comments
 (0)