Skip to content

Commit c4f555d

Browse files
Dan CarpenterSomasundaram Krishnasamy
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]> (cherry picked from commit 4327981) Orabug: 30915439 Signed-off-by: Junxiao Bi <[email protected]> Reviewed-by: Joe Jin <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent dc9c5bc commit c4f555d

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
@@ -841,6 +841,8 @@ int __uio_register_device(struct module *owner,
841841
if (ret)
842842
goto err_uio_dev_add_attributes;
843843

844+
info->uio_dev = idev;
845+
844846
if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) {
845847
/*
846848
* Note that we deliberately don't use devm_request_irq
@@ -852,11 +854,12 @@ int __uio_register_device(struct module *owner,
852854
*/
853855
ret = request_irq(info->irq, uio_interrupt,
854856
info->irq_flags, info->name, idev);
855-
if (ret)
857+
if (ret) {
858+
info->uio_dev = NULL;
856859
goto err_request_irq;
860+
}
857861
}
858862

859-
info->uio_dev = idev;
860863
return 0;
861864

862865
err_request_irq:

0 commit comments

Comments
 (0)