From: Sascha Hauer <s.hauer@pengutronix.de>
To: Stefan Lengfeld <s.lengfeld@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] commands: spi: fix chip select validation
Date: Tue, 8 Nov 2016 08:56:03 +0100 [thread overview]
Message-ID: <20161108075603.7o42xbpmspomojwh@pengutronix.de> (raw)
In-Reply-To: <1478531456-11232-1-git-send-email-s.lengfeld@phytec.de>
On Mon, Nov 07, 2016 at 04:10:56PM +0100, Stefan Lengfeld wrote:
> The chip selects are numbered 0..(max chip selects - 1). Chip select
> with number <max chip selects> is invalid. Fix the check for that. Using
> the out of bound chip select may hang your board.
>
> Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>
> ---
> commands/spi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/commands/spi.c b/commands/spi.c
> index 21db9ae..6603b34 100644
> --- a/commands/spi.c
> +++ b/commands/spi.c
> @@ -68,8 +68,8 @@ static int do_spi(int argc, char *argv[])
> return -ENODEV;
> }
>
> - if (spi.chip_select > spi.master->num_chipselect) {
> - printf("spi chip select (%d)> master num chipselect (%d)\n",
> + if (spi.chip_select >= spi.master->num_chipselect) {
> + printf("spi chip select (%d) >= master num chipselect (%d)\n",
> spi.chip_select, spi.master->num_chipselect);
> return -EINVAL;
> }
> --
> 1.9.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2016-11-08 7:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 15:10 Stefan Lengfeld
2016-11-08 7:56 ` Sascha Hauer [this message]
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=20161108075603.7o42xbpmspomojwh@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.lengfeld@phytec.de \
/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