* [PATCH] ARM: STi: at least warn if of_iomap fails
@ 2018-07-12 15:48 Nicholas Mc Guire
2018-07-16 7:55 ` Patrice CHOTARD
0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Mc Guire @ 2018-07-12 15:48 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Patrice Chotard, Russell King, linux-arm-kernel, linux-kernel,
Nicholas Mc Guire
The call to of_iomap() is unchecked but scu_enable(), which the returned
address is passed on to, assumes a valid mapping. If the mapping is
invalid this could probably lead to undefined system state so at least
a warning should be issued.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: commit 65ebcc115889 ("ARM: sti: Add STiH415 SOC support")
---
Problem was found by an experimental coccinelle script
Patch was compile tested with: multi_v7_defconfig (implies
CONFIG_ARCH_STI=y, CONFIG_SMP=y)
Patch is against 4.18-rc3 (localversion-next is next-20180712)
arch/arm/mach-sti/platsmp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-sti/platsmp.c b/arch/arm/mach-sti/platsmp.c
index 231f19e..89ae76f 100644
--- a/arch/arm/mach-sti/platsmp.c
+++ b/arch/arm/mach-sti/platsmp.c
@@ -109,6 +109,7 @@ static void __init sti_smp_prepare_cpus(unsigned int max_cpus)
if (np) {
scu_base = of_iomap(np, 0);
+ WARN_ON(!scu_base);
scu_enable(scu_base);
of_node_put(np);
}
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ARM: STi: at least warn if of_iomap fails
2018-07-12 15:48 [PATCH] ARM: STi: at least warn if of_iomap fails Nicholas Mc Guire
@ 2018-07-16 7:55 ` Patrice CHOTARD
2018-07-16 8:46 ` Nicholas Mc Guire
0 siblings, 1 reply; 4+ messages in thread
From: Patrice CHOTARD @ 2018-07-16 7:55 UTC (permalink / raw)
To: Nicholas Mc Guire, Srinivas Kandagatla
Cc: Russell King, linux-arm-kernel, linux-kernel
Hi Nicholas
On 07/12/2018 05:48 PM, Nicholas Mc Guire wrote:
> The call to of_iomap() is unchecked but scu_enable(), which the returned
> address is passed on to, assumes a valid mapping. If the mapping is
> invalid this could probably lead to undefined system state so at least
> a warning should be issued.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> Fixes: commit 65ebcc115889 ("ARM: sti: Add STiH415 SOC support")
> ---
> Problem was found by an experimental coccinelle script
>
> Patch was compile tested with: multi_v7_defconfig (implies
> CONFIG_ARCH_STI=y, CONFIG_SMP=y)
>
> Patch is against 4.18-rc3 (localversion-next is next-20180712)
>
> arch/arm/mach-sti/platsmp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/mach-sti/platsmp.c b/arch/arm/mach-sti/platsmp.c
> index 231f19e..89ae76f 100644
> --- a/arch/arm/mach-sti/platsmp.c
> +++ b/arch/arm/mach-sti/platsmp.c
> @@ -109,6 +109,7 @@ static void __init sti_smp_prepare_cpus(unsigned int max_cpus)
>
> if (np) {
> scu_base = of_iomap(np, 0);
> + WARN_ON(!scu_base);
> scu_enable(scu_base);
> of_node_put(np);
> }
>
I should prefer to exit with an error to avoid unpredictable behavior,
something like this is better :
scu_base = of_iomap(np, 0);
of_node_put(np);
if (!scu_base) {
pr_err("No SCU remap\n");
return;
}
scu_enable(scu_base);
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ARM: STi: at least warn if of_iomap fails
2018-07-16 7:55 ` Patrice CHOTARD
@ 2018-07-16 8:46 ` Nicholas Mc Guire
0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Mc Guire @ 2018-07-16 8:46 UTC (permalink / raw)
To: Patrice CHOTARD
Cc: Nicholas Mc Guire, Srinivas Kandagatla, Russell King,
linux-arm-kernel, linux-kernel
On Mon, Jul 16, 2018 at 07:55:08AM +0000, Patrice CHOTARD wrote:
> Hi Nicholas
>
> On 07/12/2018 05:48 PM, Nicholas Mc Guire wrote:
> > The call to of_iomap() is unchecked but scu_enable(), which the returned
> > address is passed on to, assumes a valid mapping. If the mapping is
> > invalid this could probably lead to undefined system state so at least
> > a warning should be issued.
> >
> > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> > Fixes: commit 65ebcc115889 ("ARM: sti: Add STiH415 SOC support")
> > ---
> > Problem was found by an experimental coccinelle script
> >
> > Patch was compile tested with: multi_v7_defconfig (implies
> > CONFIG_ARCH_STI=y, CONFIG_SMP=y)
> >
> > Patch is against 4.18-rc3 (localversion-next is next-20180712)
> >
> > arch/arm/mach-sti/platsmp.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/arm/mach-sti/platsmp.c b/arch/arm/mach-sti/platsmp.c
> > index 231f19e..89ae76f 100644
> > --- a/arch/arm/mach-sti/platsmp.c
> > +++ b/arch/arm/mach-sti/platsmp.c
> > @@ -109,6 +109,7 @@ static void __init sti_smp_prepare_cpus(unsigned int max_cpus)
> >
> > if (np) {
> > scu_base = of_iomap(np, 0);
> > + WARN_ON(!scu_base);
> > scu_enable(scu_base);
> > of_node_put(np);
> > }
> >
>
> I should prefer to exit with an error to avoid unpredictable behavior,
> something like this is better :
>
> scu_base = of_iomap(np, 0);
> of_node_put(np);
> if (!scu_base) {
> pr_err("No SCU remap\n");
> return;
> }
>
> scu_enable(scu_base);
>
even though it would be possible to locate that then from that message
would it not be prefereable to provide the infos upfront like:
pr_err("SCU remap failed at %s:%s():%d\n",
__FILE__, __func__, __LINE__);
if that makes sense I´ll resend - or is that considered too verbouse ?
thx!
hofrat
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 0/4] ARM: imx legacy: cleanups
@ 2019-04-13 7:14 Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH] ARM: STi: at least warn if of_iomap fails Nicholas Mc Guire
0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Mc Guire @ 2019-04-13 7:14 UTC (permalink / raw)
To: Russell King
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
NXP Linux Team, Mark Brown, Linus Walleij, Tony Lindgren,
Mike Rapoport, Janusz Krzysztofik, linux-arm-kernel,
linux-kernel, Nicholas Mc Guire
While preparing a proposed fix for a missing check on zmalloc a few
other checkpatch warnings poped up - this little set fixes those
warnings. There is one remaining checkpatch warning but that looks
like a false-positive to me:
ERROR: Use of __initconst requires a separate use of const
#171: FILE: arch/arm/mach-imx/mach-mx27ads.c:171:
+mx27ads_nand_board_info __initconst = {
The false positive seems due to the definition spanning two lines
anyway looks good to me
<snip>
static const struct mxc_nand_platform_data
mx27ads_nand_board_info __initconst = {
.width = 1,
.hw_ecc = 1,
};
<snip>
thx!
hofrat
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ARM: STi: at least warn if of_iomap fails
2019-04-13 7:14 [PATCH 0/4] ARM: imx legacy: cleanups Nicholas Mc Guire
@ 2019-04-13 7:14 ` Nicholas Mc Guire
0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Mc Guire @ 2019-04-13 7:14 UTC (permalink / raw)
To: Russell King
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
NXP Linux Team, Mark Brown, Linus Walleij, Tony Lindgren,
Mike Rapoport, Janusz Krzysztofik, linux-arm-kernel,
linux-kernel, Nicholas Mc Guire
The call to of_iomap() is unchecked but scu_enable(), which the returned
address is passed on to, assumes a valid mapping. If the mapping is
invalid this could probably lead to undefined system state so at least
a warning should be issued.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: commit 65ebcc115889 ("ARM: sti: Add STiH415 SOC support")
---
Problem was found by an experimental coccinelle script
Patch was compile tested with: multi_v7_defconfig (implies
CONFIG_ARCH_STI=y, CONFIG_SMP=y)
Patch is against 4.18-rc3 (localversion-next is next-20180712)
arch/arm/mach-sti/platsmp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-sti/platsmp.c b/arch/arm/mach-sti/platsmp.c
index 231f19e..89ae76f 100644
--- a/arch/arm/mach-sti/platsmp.c
+++ b/arch/arm/mach-sti/platsmp.c
@@ -109,6 +109,7 @@ static void __init sti_smp_prepare_cpus(unsigned int max_cpus)
if (np) {
scu_base = of_iomap(np, 0);
+ WARN_ON(!scu_base);
scu_enable(scu_base);
of_node_put(np);
}
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-13 7:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-12 15:48 [PATCH] ARM: STi: at least warn if of_iomap fails Nicholas Mc Guire
2018-07-16 7:55 ` Patrice CHOTARD
2018-07-16 8:46 ` Nicholas Mc Guire
2019-04-13 7:14 [PATCH 0/4] ARM: imx legacy: cleanups Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH] ARM: STi: at least warn if of_iomap fails Nicholas Mc Guire
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).