public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>
Cc: Tom Rini <trini@konsulko.com>,
	Daniel Schwierzeck <daniel.schwierzeck@gmail.com>,
	Peng Fan <peng.fan@nxp.com>, Weijie Gao <weijie.gao@mediatek.com>
Subject: Re: [PATCH 01/15] spl: nand: Fix NULL-pointer dereference
Date: Sun, 29 Oct 2023 10:15:23 -0400	[thread overview]
Message-ID: <20a22ee2-2060-3e6a-61ea-963786f4e4f1@gmail.com> (raw)
In-Reply-To: <20231029034845.1169614-2-seanga2@gmail.com>

On 10/28/23 23:48, Sean Anderson wrote:
> spl_nand_fit_read unconditionally accesses load->priv. Ensure it is set.
> 
> Fixes: 00e180cc513 ("spl: nand: support loading i.MX container format file")
> Fixes: 4620e8aabc1 ("spl: nand: support loading legacy image with payload compressed")
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
> 
>   common/spl/spl_nand.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
> index 07916bedbb9..a19236d9e6d 100644
> --- a/common/spl/spl_nand.c
> +++ b/common/spl/spl_nand.c
> @@ -105,7 +105,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
>   		struct spl_load_info load;
>   
>   		load.dev = NULL;
> -		load.priv = NULL;
> +		load.priv = &offset;
>   		load.filename = NULL;
>   		load.bl_len = bl_len;
>   		load.read = spl_nand_fit_read;
> @@ -116,7 +116,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
>   
>   		debug("Found legacy image\n");
>   		load.dev = NULL;
> -		load.priv = NULL;
> +		load.priv = &offset;
>   		load.filename = NULL;
>   		load.bl_len = 1;
>   		load.read = spl_nand_legacy_read;

Actually, since spl_nand_legacy_read doesn't reference priv, this second hunk is
unnecessary. Actually, spl_nand_legacy_read and spl_load_legacy_img are technically buggy
since size/offset are supposed to be in units of bl_len. However, this basically just
results in extra multiplies and divides, so I don't think it's desirable. I actually have
a patch to convert everything to bytes (keeping alignment), so "fixing" this is not
necessary for the moment.

--Sean

  reply	other threads:[~2023-10-29 14:15 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-29  3:48 [PATCH 00/15] nand: Add sandbox tests Sean Anderson
2023-10-29  3:48 ` [PATCH 01/15] spl: nand: Fix NULL-pointer dereference Sean Anderson
2023-10-29 14:15   ` Sean Anderson [this message]
2023-10-29  3:48 ` [PATCH 02/15] nand: Don't dereference NULL manufacturer_desc Sean Anderson
2023-10-29 13:06   ` Michael Nazzareno Trimarchi
2023-10-29  3:48 ` [PATCH 03/15] nand: Calculate SYS_NAND_PAGE_COUNT automatically Sean Anderson
2023-11-02  9:53   ` Dario Binacchi
2023-11-02 14:17     ` Sean Anderson
2023-11-02 14:19       ` Dario Binacchi
2023-10-29  3:48 ` [PATCH 04/15] nand: spl_loaders: Only read enough pages to load the image Sean Anderson
2023-10-29 13:08   ` Michael Nazzareno Trimarchi
2023-10-29  3:48 ` [PATCH 05/15] spl: legacy: Honor bl_len when decompressing Sean Anderson
2023-10-29  3:48 ` [PATCH 06/15] spl: nand: Set bl_len to page size Sean Anderson
2023-10-29  3:48 ` [PATCH 07/15] cmd: nand: Map memory before accessing it Sean Anderson
2023-10-29  3:48 ` [PATCH 08/15] spl: " Sean Anderson
2023-10-29  3:48 ` [PATCH 09/15] mtd: Rename SPL_MTD_SUPPORT to SPL_MTD Sean Anderson
2023-10-29  3:48 ` [PATCH 10/15] mtd: Add some fallbacks for add/del_mtd_device Sean Anderson
2023-11-02 10:45   ` Dario Binacchi
2023-10-29  3:48 ` [PATCH 11/15] nand: Add function to unregister NAND devices Sean Anderson
2023-11-02 10:58   ` Dario Binacchi
2023-10-29  3:48 ` [PATCH 12/15] nand: Allow reinitialization Sean Anderson
2023-11-02 11:08   ` Dario Binacchi
2023-10-29  3:48 ` [PATCH 13/15] arch: sandbox: Add function to create temporary files Sean Anderson
2023-10-29  3:48 ` [PATCH 14/15] nand: Add sandbox driver Sean Anderson
2023-11-02 11:15   ` Dario Binacchi
2023-11-02 13:54     ` Sean Anderson
2023-10-29  3:48 ` [PATCH 15/15] test: spl: Add a test for NAND Sean Anderson
2023-11-02 14:01 ` [PATCH 00/15] nand: Add sandbox tests Dario Binacchi
2023-11-02 14:05   ` Sean Anderson
2023-11-02 14:08     ` Dario Binacchi
2023-11-02 14:13       ` Sean Anderson
2023-11-02 14:18         ` Dario Binacchi
2023-11-04 19:46           ` Sean Anderson
2023-11-09  8:23             ` Dario Binacchi

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=20a22ee2-2060-3e6a-61ea-963786f4e4f1@gmail.com \
    --to=seanga2@gmail.com \
    --cc=daniel.schwierzeck@gmail.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=michael@amarulasolutions.com \
    --cc=peng.fan@nxp.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=weijie.gao@mediatek.com \
    /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