]>
Commit | Line | Data |
---|---|---|
704fbcc2 GKH |
1 | From 432798195bbce1f8cd33d1c0284d0538835e25fb Mon Sep 17 00:00:00 2001 |
2 | From: Dan Carpenter <dan.carpenter@oracle.com> | |
3 | Date: Fri, 26 Oct 2018 10:19:51 +0300 | |
4 | Subject: uio: Fix an Oops on load | |
5 | ||
6 | From: Dan Carpenter <dan.carpenter@oracle.com> | |
7 | ||
8 | commit 432798195bbce1f8cd33d1c0284d0538835e25fb upstream. | |
9 | ||
10 | I was trying to solve a double free but I introduced a more serious | |
11 | NULL dereference bug. The problem is that if there is an IRQ which | |
12 | triggers immediately, then we need "info->uio_dev" but it's not set yet. | |
13 | ||
14 | This patch puts the original initialization back to how it was and just | |
15 | sets info->uio_dev to NULL on the error path so it should solve both | |
16 | the Oops and the double free. | |
17 | ||
18 | Fixes: f019f07ecf6a ("uio: potential double frees if __uio_register_device() fails") | |
19 | Reported-by: Mathias Thore <Mathias.Thore@infinera.com> | |
20 | Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> | |
21 | Cc: stable <stable@vger.kernel.org> | |
22 | Tested-by: Mathias Thore <Mathias.Thore@infinera.com> | |
23 | Signed-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: |