Commit 7cbc2579 authored by Dan Carpenter's avatar Dan Carpenter Committed by Kleber Sacilotto de Souza

uio: Fix an Oops on load

BugLink: https://bugs.launchpad.net/bugs/1810958

commit 43279819 upstream.

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: f019f07e ("uio: potential double frees if __uio_register_device() fails")
Reported-by: default avatarMathias Thore <Mathias.Thore@infinera.com>
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Tested-by: default avatarMathias Thore <Mathias.Thore@infinera.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 1f84854c
......@@ -842,6 +842,8 @@ int __uio_register_device(struct module *owner,
if (ret)
goto err_uio_dev_add_attributes;
info->uio_dev = idev;
if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) {
/*
* Note that we deliberately don't use devm_request_irq
......@@ -853,11 +855,12 @@ int __uio_register_device(struct module *owner,
*/
ret = request_irq(info->irq, uio_interrupt,
info->irq_flags, info->name, idev);
if (ret)
if (ret) {
info->uio_dev = NULL;
goto err_request_irq;
}
}
info->uio_dev = idev;
return 0;
err_request_irq:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment