]>
Commit | Line | Data |
---|---|---|
3d4ecfe4 SL |
1 | From 9ecc43cd2ee9849cc80e8ace0b3d08f89277029d Mon Sep 17 00:00:00 2001 |
2 | From: Kangjie Lu <kjlu@umn.edu> | |
3 | Date: Fri, 15 Mar 2019 02:07:12 -0500 | |
4 | Subject: tty: ipwireless: fix missing checks for ioremap | |
5 | ||
6 | [ Upstream commit 1bbb1c318cd8a3a39e8c3e2e83d5e90542d6c3e3 ] | |
7 | ||
8 | ipw->attr_memory and ipw->common_memory are assigned with the | |
9 | return value of ioremap. ioremap may fail, but no checks | |
10 | are enforced. The fix inserts the checks to avoid potential | |
11 | NULL pointer dereferences. | |
12 | ||
13 | Signed-off-by: Kangjie Lu <kjlu@umn.edu> | |
14 | Reviewed-by: David Sterba <dsterba@suse.com> | |
15 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
16 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
17 | --- | |
18 | drivers/tty/ipwireless/main.c | 8 ++++++++ | |
19 | 1 file changed, 8 insertions(+) | |
20 | ||
21 | diff --git a/drivers/tty/ipwireless/main.c b/drivers/tty/ipwireless/main.c | |
22 | index 655c7948261c7..2fa4f91234693 100644 | |
23 | --- a/drivers/tty/ipwireless/main.c | |
24 | +++ b/drivers/tty/ipwireless/main.c | |
25 | @@ -113,6 +113,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) | |
26 | ||
27 | ipw->common_memory = ioremap(p_dev->resource[2]->start, | |
28 | resource_size(p_dev->resource[2])); | |
29 | + if (!ipw->common_memory) { | |
30 | + ret = -ENOMEM; | |
31 | + goto exit1; | |
32 | + } | |
33 | if (!request_mem_region(p_dev->resource[2]->start, | |
34 | resource_size(p_dev->resource[2]), | |
35 | IPWIRELESS_PCCARD_NAME)) { | |
36 | @@ -133,6 +137,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) | |
37 | ||
38 | ipw->attr_memory = ioremap(p_dev->resource[3]->start, | |
39 | resource_size(p_dev->resource[3])); | |
40 | + if (!ipw->attr_memory) { | |
41 | + ret = -ENOMEM; | |
42 | + goto exit3; | |
43 | + } | |
44 | if (!request_mem_region(p_dev->resource[3]->start, | |
45 | resource_size(p_dev->resource[3]), | |
46 | IPWIRELESS_PCCARD_NAME)) { | |
47 | -- | |
48 | 2.20.1 | |
49 |