From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/6] arm: zynq: platsmp: Fix CPU presence check
Date: Thu, 31 Oct 2013 16:17:39 +0000 [thread overview]
Message-ID: <20131031161739.GE16735@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1383235819-2552-2-git-send-email-soren.brinkmann@xilinx.com>
On Thu, Oct 31, 2013 at 09:10:14AM -0700, Soren Brinkmann wrote:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> Fix an off-by-one error in the logic that checks if a CPU is present.
> The ncores variable is a count of cores while the cpu variable is a
> 0 based index. So if ncores == cpu, cpu is out of range. Fix this
> comparison so non-existent CPUs are not probed.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
There's another two bugs here.
> ---
> arch/arm/mach-zynq/platsmp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-zynq/platsmp.c b/arch/arm/mach-zynq/platsmp.c
> index 689fbbc3d9c8..2512624e657d 100644
> --- a/arch/arm/mach-zynq/platsmp.c
> +++ b/arch/arm/mach-zynq/platsmp.c
> @@ -39,7 +39,7 @@ int zynq_cpun_start(u32 address, int cpu)
> u32 trampoline_code_size = &zynq_secondary_trampoline_end -
> &zynq_secondary_trampoline;
>
> - if (cpu > ncores) {
> + if (cpu >= ncores) {
> pr_warn("CPU No. is not available in the system\n");
Much better: pr_warn("CPU%d is not available\n", cpu);
However, if you have set the cpu possible/present masks correctly,
you will never hit this because the generic code already checks that
the CPU being requested is legal. So actually I'd suggest getting
rid of this entire if() statement and block.
> return -1;
The second issue is one of laziness. -1 as a return code for something
that gets propagated back to userspace. Do we really mean to return to
userspace -EPERM because of this or other failures in this function?
All those idiotic and lazy (and that's exactly what they are - idiotic
and lazy) "return -1" statements need to be fixed.
Shame on the arm-soc maintainers for not having an automatic filter for
this kind of sloppy programming.
next prev parent reply other threads:[~2013-10-31 16:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-31 16:10 [PATCH 0/6] arm: zynq: BSP update Soren Brinkmann
2013-10-31 16:10 ` [PATCH 1/6] arm: zynq: platsmp: Fix CPU presence check Soren Brinkmann
2013-10-31 16:17 ` Russell King - ARM Linux [this message]
2013-10-31 17:37 ` [PATCH] arm: zynq: platsmp: Remove " Soren Brinkmann
2013-10-31 16:42 ` [PATCH 1/6] arm: zynq: platsmp: Fix " Sudeep KarkadaNagesha
2013-10-31 16:10 ` [PATCH 2/6] arm: zynq: Invalidate L1 in secondary boot Soren Brinkmann
2013-10-31 16:10 ` [PATCH 3/6] arm: zynq: Add support for zynq_cpu_kill function Soren Brinkmann
2013-10-31 16:10 ` [PATCH 4/6] arm: zynq: Use of_platform_populate instead of bus_probe Soren Brinkmann
2013-10-31 16:10 ` [PATCH 5/6] arm: zynq: Set proper GIC flags Soren Brinkmann
2013-10-31 16:10 ` [PATCH 6/6] arm: zynq: headsmp: Move .glbl out of actual code Soren Brinkmann
2013-11-06 7:46 ` Michal Simek
2013-11-06 16:41 ` Sören Brinkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131031161739.GE16735@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).