* [PATCH] mtd: gpio_flash: add error handling for ioremap_nocache
@ 2018-06-12 3:15 ` Zhouyang Jia
0 siblings, 0 replies; 6+ messages in thread
From: Zhouyang Jia @ 2018-06-12 3:15 UTC (permalink / raw)
Cc: Zhouyang Jia, David Woodhouse, Brian Norris, Boris Brezillon,
Marek Vasut, Richard Weinberger, linux-mtd, linux-kernel
When ioremap_nocache fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling ioremap_nocache.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
drivers/mtd/maps/gpio-addr-flash.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
index 385305e..7fbba02 100644
--- a/drivers/mtd/maps/gpio-addr-flash.c
+++ b/drivers/mtd/maps/gpio-addr-flash.c
@@ -242,6 +242,9 @@ static int gpio_flash_probe(struct platform_device *pdev)
state->map.phys = NO_XIP;
state->map.map_priv_1 = (unsigned long)state;
+ if (!state->map.virt)
+ return -ENOMEM;
+
platform_set_drvdata(pdev, state);
i = 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] mtd: gpio_flash: add error handling for ioremap_nocache
@ 2018-06-12 3:15 ` Zhouyang Jia
0 siblings, 0 replies; 6+ messages in thread
From: Zhouyang Jia @ 2018-06-12 3:15 UTC (permalink / raw)
Cc: Zhouyang Jia, David Woodhouse, Brian Norris, Boris Brezillon,
Marek Vasut, Richard Weinberger, linux-mtd, linux-kernel
When ioremap_nocache fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling ioremap_nocache.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
drivers/mtd/maps/gpio-addr-flash.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
index 385305e..7fbba02 100644
--- a/drivers/mtd/maps/gpio-addr-flash.c
+++ b/drivers/mtd/maps/gpio-addr-flash.c
@@ -242,6 +242,9 @@ static int gpio_flash_probe(struct platform_device *pdev)
state->map.phys = NO_XIP;
state->map.map_priv_1 = (unsigned long)state;
+ if (!state->map.virt)
+ return -ENOMEM;
+
platform_set_drvdata(pdev, state);
i = 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: gpio_flash: add error handling for ioremap_nocache
2018-06-12 3:15 ` Zhouyang Jia
(?)
@ 2018-06-21 22:21 ` Boris Brezillon
-1 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2018-06-21 22:21 UTC (permalink / raw)
To: Zhouyang Jia
Cc: Richard Weinberger, linux-kernel, Marek Vasut, linux-mtd,
Brian Norris, David Woodhouse
On Tue, 12 Jun 2018 11:15:00 +0800
Zhouyang Jia <jiazhouyang09@gmail.com> wrote:
> When ioremap_nocache fails, the lack of error-handling code may
> cause unexpected results.
>
> This patch adds error-handling code after calling ioremap_nocache.
>
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> drivers/mtd/maps/gpio-addr-flash.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
> index 385305e..7fbba02 100644
> --- a/drivers/mtd/maps/gpio-addr-flash.c
> +++ b/drivers/mtd/maps/gpio-addr-flash.c
> @@ -242,6 +242,9 @@ static int gpio_flash_probe(struct platform_device *pdev)
> state->map.phys = NO_XIP;
> state->map.map_priv_1 = (unsigned long)state;
>
> + if (!state->map.virt)
> + return -ENOMEM;
Please move the test just after the ioremap_nocache() call. Also, I see
that iounmap() is never called. Probably a good opportunity to switch
to devm_ funcs.
> +
> platform_set_drvdata(pdev, state);
>
> i = 0;
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] mtd: gpio_flash: add error handling for ioremap_nocache
2018-06-12 3:15 ` Zhouyang Jia
@ 2018-06-22 1:52 ` Zhouyang Jia
-1 siblings, 0 replies; 6+ messages in thread
From: Zhouyang Jia @ 2018-06-22 1:52 UTC (permalink / raw)
Cc: Zhouyang Jia, David Woodhouse, Brian Norris, Boris Brezillon,
Marek Vasut, Richard Weinberger, linux-mtd, linux-kernel
When ioremap_nocache fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling ioremap_nocache.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
v1->v2:
- Move the test just after the ioremap_nocache() call.
---
drivers/mtd/maps/gpio-addr-flash.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
index 385305e..9d97236 100644
--- a/drivers/mtd/maps/gpio-addr-flash.c
+++ b/drivers/mtd/maps/gpio-addr-flash.c
@@ -239,6 +239,9 @@ static int gpio_flash_probe(struct platform_device *pdev)
state->map.bankwidth = pdata->width;
state->map.size = state->win_size * (1 << state->gpio_count);
state->map.virt = ioremap_nocache(memory->start, state->map.size);
+ if (!state->map.virt)
+ return -ENOMEM;
+
state->map.phys = NO_XIP;
state->map.map_priv_1 = (unsigned long)state;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2] mtd: gpio_flash: add error handling for ioremap_nocache
@ 2018-06-22 1:52 ` Zhouyang Jia
0 siblings, 0 replies; 6+ messages in thread
From: Zhouyang Jia @ 2018-06-22 1:52 UTC (permalink / raw)
Cc: Zhouyang Jia, David Woodhouse, Brian Norris, Boris Brezillon,
Marek Vasut, Richard Weinberger, linux-mtd, linux-kernel
When ioremap_nocache fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling ioremap_nocache.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
v1->v2:
- Move the test just after the ioremap_nocache() call.
---
drivers/mtd/maps/gpio-addr-flash.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
index 385305e..9d97236 100644
--- a/drivers/mtd/maps/gpio-addr-flash.c
+++ b/drivers/mtd/maps/gpio-addr-flash.c
@@ -239,6 +239,9 @@ static int gpio_flash_probe(struct platform_device *pdev)
state->map.bankwidth = pdata->width;
state->map.size = state->win_size * (1 << state->gpio_count);
state->map.virt = ioremap_nocache(memory->start, state->map.size);
+ if (!state->map.virt)
+ return -ENOMEM;
+
state->map.phys = NO_XIP;
state->map.map_priv_1 = (unsigned long)state;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mtd: gpio_flash: add error handling for ioremap_nocache
2018-06-22 1:52 ` Zhouyang Jia
(?)
@ 2018-07-07 9:59 ` Boris Brezillon
-1 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2018-07-07 9:59 UTC (permalink / raw)
To: Zhouyang Jia
Cc: David Woodhouse, Brian Norris, Marek Vasut, Richard Weinberger,
linux-mtd, linux-kernel
On Fri, 22 Jun 2018 09:52:20 +0800
Zhouyang Jia <jiazhouyang09@gmail.com> wrote:
> When ioremap_nocache fails, the lack of error-handling code may
> cause unexpected results.
>
> This patch adds error-handling code after calling ioremap_nocache.
>
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
Applied.
Thanks,
Boris
> ---
> v1->v2:
> - Move the test just after the ioremap_nocache() call.
> ---
> drivers/mtd/maps/gpio-addr-flash.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
> index 385305e..9d97236 100644
> --- a/drivers/mtd/maps/gpio-addr-flash.c
> +++ b/drivers/mtd/maps/gpio-addr-flash.c
> @@ -239,6 +239,9 @@ static int gpio_flash_probe(struct platform_device *pdev)
> state->map.bankwidth = pdata->width;
> state->map.size = state->win_size * (1 << state->gpio_count);
> state->map.virt = ioremap_nocache(memory->start, state->map.size);
> + if (!state->map.virt)
> + return -ENOMEM;
> +
> state->map.phys = NO_XIP;
> state->map.map_priv_1 = (unsigned long)state;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-07-07 9:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 3:15 [PATCH] mtd: gpio_flash: add error handling for ioremap_nocache Zhouyang Jia
2018-06-12 3:15 ` Zhouyang Jia
2018-06-21 22:21 ` Boris Brezillon
2018-06-22 1:52 ` [PATCH v2] " Zhouyang Jia
2018-06-22 1:52 ` Zhouyang Jia
2018-07-07 9:59 ` Boris Brezillon
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.