From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] fixup! pblimage: pblimage: Add LS1028a support
Date: Wed, 10 Jan 2024 15:34:00 +0100 [thread overview]
Message-ID: <20240110143400.GR1318922@pengutronix.de> (raw)
In-Reply-To: <20240110091538.3130283-1-a.fatoum@pengutronix.de>
On Wed, Jan 10, 2024 at 10:15:38AM +0100, Ahmad Fatoum wrote:
> soc_index is not only used for comparisons, but also as index into the
> socs[] array. However, the array starts with SOC_TYPE_LS1046A and the
> enum with SOC_TYPE_INVALID leading to socs[SOC_TYPE_LS1046A].soc
> == SOC_TYPE_LS1028A and socs[SOC_TYPE_LS1028A] to overflow the array.
>
> This broke LS1046A boot and LS1028A seems to have only worked by chance,
> because the memory after socs[] happened to be zeroed.
>
> Fix this by reordering the enum and while at it remove the redundancy in
> having both the index and the soc member be the same value.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> scripts/pblimage.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/scripts/pblimage.c b/scripts/pblimage.c
> index 8cb473d5bcf2..ef09b0f96084 100644
> --- a/scripts/pblimage.c
> +++ b/scripts/pblimage.c
> @@ -57,30 +57,28 @@ static uint32_t pbi_crc_cmd1;
> static uint32_t pbi_crc_cmd2;
>
> enum soc_type {
> - SOC_TYPE_INVALID,
> + SOC_TYPE_INVALID = -1,
> SOC_TYPE_LS1046A,
> SOC_TYPE_LS1028A,
> };
>
> struct soc_type_entry {
> const char *name;
> - enum soc_type soc;
> bool big_endian;
> };
>
> static struct soc_type_entry socs[] = {
> - {
> + [SOC_TYPE_LS1046A] = {
> .name = "ls1046a",
> - .soc = SOC_TYPE_LS1046A,
> .big_endian = true,
> - }, {
> + },
> + [SOC_TYPE_LS1028A] = {
> .name = "ls1028a",
> - .soc = SOC_TYPE_LS1028A,
> .big_endian = false,
> },
> };
>
> -static enum soc_type soc_type;
> +static enum soc_type soc_type = SOC_TYPE_INVALID;
>
> static char *rcwfile;
> static char *pbifile;
> @@ -413,7 +411,7 @@ int main(int argc, char *argv[])
>
> for (i = 0; i < ARRAY_SIZE(socs); i++) {
> if (!strcmp(socs[i].name, cputypestr)) {
> - soc_type = socs[i].soc;
> + soc_type = i;
> break;
> }
> }
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2024-01-10 14:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 9:15 Ahmad Fatoum
2024-01-10 9:17 ` Ahmad Fatoum
2024-01-10 14:34 ` 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=20240110143400.GR1318922@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@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