tty: ipwireless: fix missing checks for ioremap
PATCH 1/1 tty: ipwireless: fix missing checks for ioremap
ipw->attr_memory and ipw->common_memory are assigned with the
return value of ioremap. ioremap may fail, but not checks
are enforced. The fix insertss the checks.
Signed-off-by Kangjie Lu <[email protected]>
--- drivers/tty/ipwireless/main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/tty/ipwireless/main.c +8 -0
@@ -114,6 +114,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) ipw->common_memory =ioremap (p_dev->resource[2 ]->start,resource_size (p_dev->resource[2 ])); +if (!ipw->common_memory) { + ret = -ENOMEM ; + goto exit1; + }if (!request_mem_region (p_dev->resource[2 ]->start,resource_size (p_dev->resource[2 ]),IPWIRELESS_PCCARD_NAME )) {
@@ -134,6 +138,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) ipw->attr_memory =ioremap (p_dev->resource[3 ]->start,resource_size (p_dev->resource[3 ])); +if (!ipw->attr_memory) { + ret = -ENOMEM ; + goto exit3; + }if (!request_mem_region (p_dev->resource[3 ]->start,resource_size (p_dev->resource[3 ]),IPWIRELESS_PCCARD_NAME )) {
Signature · 1 line
2.17.1
Quoted 3 lines · Kangjie Lu
ipw->attr_memoryandipw->common_memoryare assigned with the
return value of ioremap. ioremap may fail, but not checks
are enforced. The fix insertss the checks.
Please fix the typos and resend, otherwise ok. Thanks.
Quoted 2 lines
Signed-off-by Kangjie Lu <[email protected]>
Reviewed-by David Sterba <[email protected]>
PATCH v2 1/1 tty: ipwireless: fix missing checks for ioremap
ipw->attr_memory and ipw->common_memory are assigned with the return value of ioremap. ioremap may fail, but no checks are enforced. The fix inserts the checks to avoid potential NULL pointer dereferences.
Signed-off-by Kangjie Lu <[email protected]>
Reviewed-by David Sterba <[email protected]>
---
V2: fix typos
--- drivers/tty/ipwireless/main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/tty/ipwireless/main.c +8 -0
@@ -114,6 +114,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) ipw->common_memory =ioremap (p_dev->resource[2 ]->start,resource_size (p_dev->resource[2 ])); +if (!ipw->common_memory) { + ret = -ENOMEM ; + goto exit1; + }if (!request_mem_region (p_dev->resource[2 ]->start,resource_size (p_dev->resource[2 ]),IPWIRELESS_PCCARD_NAME )) {
@@ -134,6 +138,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) ipw->attr_memory =ioremap (p_dev->resource[3 ]->start,resource_size (p_dev->resource[3 ])); +if (!ipw->attr_memory) { + ret = -ENOMEM ; + goto exit3; + }if (!request_mem_region (p_dev->resource[3 ]->start,resource_size (p_dev->resource[3 ]),IPWIRELESS_PCCARD_NAME )) {
Signature · 1 line
2.17.1