All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: wireless: fix missing checks for ioremap
@ 2019-03-11  7:54 Kangjie Lu
  2019-03-23  3:58 ` Kangjie Lu
  2019-04-26 11:48 ` Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: Kangjie Lu @ 2019-03-11  7:54 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Kalle Valo, David S. Miller, linux-wireless, netdev,
	linux-kernel

ioremap could fail and returns NULL. The fix actively checks
its return value and handles potential failures.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/wireless/ray_cs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 44a943d18b84..cecd18a2f2de 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -394,6 +394,10 @@ static int ray_config(struct pcmcia_device *link)
 		goto failed;
 	local->sram = ioremap(link->resource[2]->start,
 			resource_size(link->resource[2]));
+	if (!local->sram) {
+		ret = -ENOMEM;
+		goto failed;
+	}
 
 /*** Set up 16k window for shared memory (receive buffer) ***************/
 	link->resource[3]->flags |=
@@ -408,6 +412,10 @@ static int ray_config(struct pcmcia_device *link)
 		goto failed;
 	local->rmem = ioremap(link->resource[3]->start,
 			resource_size(link->resource[3]));
+	if (!local->rmem) {
+		ret = -ENOMEM;
+		goto failed;
+	}
 
 /*** Set up window for attribute memory ***********************************/
 	link->resource[4]->flags |=
@@ -422,6 +430,10 @@ static int ray_config(struct pcmcia_device *link)
 		goto failed;
 	local->amem = ioremap(link->resource[4]->start,
 			resource_size(link->resource[4]));
+	if (!local->amem) {
+		ret = -ENOMEM;
+		goto failed;
+	}
 
 	dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram);
 	dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem);
-- 
2.17.1


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

* Re: [PATCH] net: wireless: fix missing checks for ioremap
  2019-03-11  7:54 [PATCH] net: wireless: fix missing checks for ioremap Kangjie Lu
@ 2019-03-23  3:58 ` Kangjie Lu
  2019-04-26 11:48 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kangjie Lu @ 2019-03-23  3:58 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Kalle Valo, David S. Miller, linux-wireless, netdev,
	linux-kernel


Can someone review the patch?

Thanks.

> On Mar 11, 2019, at 2:54 AM, Kangjie Lu <kjlu@umn.edu> wrote:
> 
> ioremap could fail and returns NULL. The fix actively checks
> its return value and handles potential failures.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/wireless/ray_cs.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
> index 44a943d18b84..cecd18a2f2de 100644
> --- a/drivers/net/wireless/ray_cs.c
> +++ b/drivers/net/wireless/ray_cs.c
> @@ -394,6 +394,10 @@ static int ray_config(struct pcmcia_device *link)
> 		goto failed;
> 	local->sram = ioremap(link->resource[2]->start,
> 			resource_size(link->resource[2]));
> +	if (!local->sram) {
> +		ret = -ENOMEM;
> +		goto failed;
> +	}
> 
> /*** Set up 16k window for shared memory (receive buffer) ***************/
> 	link->resource[3]->flags |=
> @@ -408,6 +412,10 @@ static int ray_config(struct pcmcia_device *link)
> 		goto failed;
> 	local->rmem = ioremap(link->resource[3]->start,
> 			resource_size(link->resource[3]));
> +	if (!local->rmem) {
> +		ret = -ENOMEM;
> +		goto failed;
> +	}
> 
> /*** Set up window for attribute memory ***********************************/
> 	link->resource[4]->flags |=
> @@ -422,6 +430,10 @@ static int ray_config(struct pcmcia_device *link)
> 		goto failed;
> 	local->amem = ioremap(link->resource[4]->start,
> 			resource_size(link->resource[4]));
> +	if (!local->amem) {
> +		ret = -ENOMEM;
> +		goto failed;
> +	}
> 
> 	dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram);
> 	dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem);
> -- 
> 2.17.1
> 


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

* Re: [PATCH] net: wireless: fix missing checks for ioremap
  2019-03-11  7:54 [PATCH] net: wireless: fix missing checks for ioremap Kangjie Lu
  2019-03-23  3:58 ` Kangjie Lu
@ 2019-04-26 11:48 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2019-04-26 11:48 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: kjlu, pakki001, David S. Miller, linux-wireless, netdev, linux-kernel

Kangjie Lu <kjlu@umn.edu> wrote:

> ioremap could fail and returns NULL. The fix actively checks
> its return value and handles potential failures.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

The prefix should be "ray_cs: ":

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#commit_title_is_wrong

Also I don't see the point of setting the ret variable as it's ignored in the failed label:

failed:
	ray_release(link);
	return -ENODEV;

Patch set to Changes Requested.

-- 
https://patchwork.kernel.org/patch/10846851/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2019-04-26 11:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11  7:54 [PATCH] net: wireless: fix missing checks for ioremap Kangjie Lu
2019-03-23  3:58 ` Kangjie Lu
2019-04-26 11:48 ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.