linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: ipwireless: fix missing checks for ioremap
@ 2019-03-14  7:05 Kangjie Lu
  2019-03-14 12:35 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Kangjie Lu @ 2019-03-14  7:05 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Jiri Kosina, David Sterba, Greg Kroah-Hartman,
	Jiri Slaby, linux-kernel

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 <kjlu@umn.edu>
---
 drivers/tty/ipwireless/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/tty/ipwireless/main.c b/drivers/tty/ipwireless/main.c
index 3475e841ef5c..4c18bbfe1a92 100644
--- a/drivers/tty/ipwireless/main.c
+++ b/drivers/tty/ipwireless/main.c
@@ -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)) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty: ipwireless: fix missing checks for ioremap
  2019-03-14  7:05 [PATCH] tty: ipwireless: fix missing checks for ioremap Kangjie Lu
@ 2019-03-14 12:35 ` David Sterba
  2019-03-15  7:07   ` [PATCH v2] " Kangjie Lu
  0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2019-03-14 12:35 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: Jiri Kosina, Greg Kroah-Hartman, Jiri Slaby, pakki001, linux-kernel

On Thu, Mar 14, 2019 at 02:05:32AM -0500, Kangjie Lu wrote:
> 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.

Please fix the typos and resend, otherwise ok. Thanks.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

Reviewed-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] tty: ipwireless: fix missing checks for ioremap
  2019-03-14 12:35 ` David Sterba
@ 2019-03-15  7:07   ` Kangjie Lu
  0 siblings, 0 replies; 3+ messages in thread
From: Kangjie Lu @ 2019-03-15  7:07 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Jiri Kosina, David Sterba, Greg Kroah-Hartman,
	Jiri Slaby, linux-kernel

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 <kjlu@umn.edu>

Reviewed-by: David Sterba <dsterba@suse.com>

---
V2: fix typos
---
 drivers/tty/ipwireless/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/tty/ipwireless/main.c b/drivers/tty/ipwireless/main.c
index 3475e841ef5c..4c18bbfe1a92 100644
--- a/drivers/tty/ipwireless/main.c
+++ b/drivers/tty/ipwireless/main.c
@@ -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)) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-15  7:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14  7:05 [PATCH] tty: ipwireless: fix missing checks for ioremap Kangjie Lu
2019-03-14 12:35 ` David Sterba
2019-03-15  7:07   ` [PATCH v2] " Kangjie Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).