summaryrefslogtreecommitdiffstats
path: root/drivers/uio/uio.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2018-10-26 03:19:51 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-11 12:21:46 -0500
commit432798195bbce1f8cd33d1c0284d0538835e25fb (patch)
treebb33155c3b0cb77622e2352520ccd95b9a377e62 /drivers/uio/uio.c
parent8bb0a88600f0267cfcc245d34f8c4abe8c282713 (diff)
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: f019f07ecf6a ("uio: potential double frees if __uio_register_device() fails") Reported-by: Mathias Thore <Mathias.Thore@infinera.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: stable <stable@vger.kernel.org> Tested-by: Mathias Thore <Mathias.Thore@infinera.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/uio/uio.c')
-rw-r--r--drivers/uio/uio.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 85644669fbe7..0a357db4b31b 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -961,6 +961,8 @@ int __uio_register_device(struct module *owner,
961 if (ret) 961 if (ret)
962 goto err_uio_dev_add_attributes; 962 goto err_uio_dev_add_attributes;
963 963
964 info->uio_dev = idev;
965
964 if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) { 966 if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) {
965 /* 967 /*
966 * Note that we deliberately don't use devm_request_irq 968 * Note that we deliberately don't use devm_request_irq
@@ -972,11 +974,12 @@ int __uio_register_device(struct module *owner,
972 */ 974 */
973 ret = request_irq(info->irq, uio_interrupt, 975 ret = request_irq(info->irq, uio_interrupt,
974 info->irq_flags, info->name, idev); 976 info->irq_flags, info->name, idev);
975 if (ret) 977 if (ret) {
978 info->uio_dev = NULL;
976 goto err_request_irq; 979 goto err_request_irq;
980 }
977 } 981 }
978 982
979 info->uio_dev = idev;
980 return 0; 983 return 0;
981 984
982err_request_irq: 985err_request_irq: