]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.165/uio-fix-an-oops-on-load.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.4.165 / uio-fix-an-oops-on-load.patch
CommitLineData
704fbcc2
GKH
1From 432798195bbce1f8cd33d1c0284d0538835e25fb Mon Sep 17 00:00:00 2001
2From: Dan Carpenter <dan.carpenter@oracle.com>
3Date: Fri, 26 Oct 2018 10:19:51 +0300
4Subject: uio: Fix an Oops on load
5
6From: Dan Carpenter <dan.carpenter@oracle.com>
7
8commit 432798195bbce1f8cd33d1c0284d0538835e25fb upstream.
9
10I was trying to solve a double free but I introduced a more serious
11NULL dereference bug. The problem is that if there is an IRQ which
12triggers immediately, then we need "info->uio_dev" but it's not set yet.
13
14This patch puts the original initialization back to how it was and just
15sets info->uio_dev to NULL on the error path so it should solve both
16the Oops and the double free.
17
18Fixes: f019f07ecf6a ("uio: potential double frees if __uio_register_device() fails")
19Reported-by: Mathias Thore <Mathias.Thore@infinera.com>
20Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
21Cc: stable <stable@vger.kernel.org>
22Tested-by: Mathias Thore <Mathias.Thore@infinera.com>
23Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25---
26 drivers/uio/uio.c | 7 +++++--
27 1 file changed, 5 insertions(+), 2 deletions(-)
28
29--- a/drivers/uio/uio.c
30+++ b/drivers/uio/uio.c
31@@ -842,6 +842,8 @@ int __uio_register_device(struct module
32 if (ret)
33 goto err_uio_dev_add_attributes;
34
35+ info->uio_dev = idev;
36+
37 if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) {
38 /*
39 * Note that we deliberately don't use devm_request_irq
40@@ -853,11 +855,12 @@ int __uio_register_device(struct module
41 */
42 ret = request_irq(info->irq, uio_interrupt,
43 info->irq_flags, info->name, idev);
44- if (ret)
45+ if (ret) {
46+ info->uio_dev = NULL;
47 goto err_request_irq;
48+ }
49 }
50
51- info->uio_dev = idev;
52 return 0;
53
54 err_request_irq: