All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
	alistair.francis@wdc.com, "Bin Meng" <bin.meng@windriver.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v5 04/11] hw/riscv/boot.c: exit early if filename is NULL in load functions
Date: Wed, 11 Jan 2023 08:29:57 +1000	[thread overview]
Message-ID: <CAKmqyKOSusV0S9RM+h4H3ZXocYjU5M8zgG8=AwoCXE0-gQ_W5Q@mail.gmail.com> (raw)
In-Reply-To: <20230102115241.25733-5-dbarboza@ventanamicro.com>

On Mon, Jan 2, 2023 at 9:54 PM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
> riscv_load_firmware(), riscv_load_initrd() and riscv_load_kernel() works
> under the assumption that a 'filename' parameter is always not NULL.
>
> This is currently the case since all callers of these functions are
> checking for NULL before calling them. Add an g_assert() to make sure
> that a NULL value in these cases are to be considered a bug.
>
> Suggested-by: Alex Bennée <alex.bennee@linaro.org>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/riscv/boot.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
> index 98b80af51b..31aa3385a0 100644
> --- a/hw/riscv/boot.c
> +++ b/hw/riscv/boot.c
> @@ -153,6 +153,8 @@ target_ulong riscv_load_firmware(const char *firmware_filename,
>      uint64_t firmware_entry, firmware_end;
>      ssize_t firmware_size;
>
> +    g_assert(firmware_filename != NULL);
> +
>      if (load_elf_ram_sym(firmware_filename, NULL, NULL, NULL,
>                           &firmware_entry, NULL, &firmware_end, NULL,
>                           0, EM_RISCV, 1, 0, NULL, true, sym_cb) > 0) {
> @@ -177,6 +179,8 @@ target_ulong riscv_load_kernel(const char *kernel_filename,
>  {
>      uint64_t kernel_load_base, kernel_entry;
>
> +    g_assert(kernel_filename != NULL);
> +
>      /*
>       * NB: Use low address not ELF entry point to ensure that the fw_dynamic
>       * behaviour when loading an ELF matches the fw_payload, fw_jump and BBL
> @@ -209,6 +213,8 @@ hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
>  {
>      ssize_t size;
>
> +    g_assert(filename != NULL);
> +
>      /*
>       * We want to put the initrd far enough into RAM that when the
>       * kernel is uncompressed it will not clobber the initrd. However
> --
> 2.39.0
>
>


  parent reply	other threads:[~2023-01-10 22:30 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-02 11:52 [PATCH v5 00/11] riscv: OpenSBI boot test and cleanups Daniel Henrique Barboza
2023-01-02 11:52 ` [PATCH v5 01/11] tests/avocado: add RISC-V OpenSBI boot test Daniel Henrique Barboza
2023-01-10 22:28   ` Alistair Francis
2023-01-02 11:52 ` [PATCH v5 02/11] hw/riscv/spike: use 'fdt' from MachineState Daniel Henrique Barboza
2023-01-02 11:52 ` [PATCH v5 03/11] hw/riscv/sifive_u: " Daniel Henrique Barboza
2023-01-02 11:52 ` [PATCH v5 04/11] hw/riscv/boot.c: exit early if filename is NULL in load functions Daniel Henrique Barboza
2023-01-08  3:30   ` Bin Meng
2023-01-10 22:29   ` Alistair Francis [this message]
2023-01-02 11:52 ` [PATCH v5 05/11] hw/riscv/spike.c: load initrd right after riscv_load_kernel() Daniel Henrique Barboza
2023-01-02 11:52 ` [PATCH v5 06/11] hw/riscv: write initrd 'chosen' FDT inside riscv_load_initrd() Daniel Henrique Barboza
2023-01-10 22:35   ` Alistair Francis
2023-01-02 11:52 ` [PATCH v5 07/11] hw/riscv: write bootargs 'chosen' FDT after riscv_load_kernel() Daniel Henrique Barboza
2023-01-10 22:37   ` Alistair Francis
2023-01-02 11:52 ` [PATCH v5 08/11] hw/riscv/boot.c: use MachineState in riscv_load_initrd() Daniel Henrique Barboza
2023-01-10 22:39   ` Alistair Francis
2023-01-02 11:52 ` [PATCH v5 09/11] hw/riscv/boot.c: use MachineState in riscv_load_kernel() Daniel Henrique Barboza
2023-01-10 22:40   ` Alistair Francis
2023-01-02 11:52 ` [PATCH v5 10/11] hw/riscv/boot.c: consolidate all kernel init " Daniel Henrique Barboza
2023-01-08  3:33   ` Bin Meng
2023-01-10 11:43     ` Daniel Henrique Barboza
2023-01-10 20:20       ` Daniel Henrique Barboza
2023-01-10 22:45         ` Alistair Francis
2023-01-10 22:42   ` Alistair Francis
2023-01-12  0:34   ` Alistair Francis
2023-01-12 13:24     ` Daniel Henrique Barboza
2023-01-13  5:23     ` Bin Meng
2023-01-13  7:16     ` Philippe Mathieu-Daudé
2023-01-13 10:21       ` Daniel Henrique Barboza
2023-01-13 10:30         ` Bin Meng
2023-01-13 10:49           ` Daniel Henrique Barboza
2023-01-02 11:52 ` [PATCH v5 11/11] hw/riscv/boot.c: make riscv_load_initrd() static Daniel Henrique Barboza
2023-01-10 22:41   ` Alistair Francis
2023-01-11  5:08 ` [PATCH v5 00/11] riscv: OpenSBI boot test and cleanups Alistair Francis

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='CAKmqyKOSusV0S9RM+h4H3ZXocYjU5M8zgG8=AwoCXE0-gQ_W5Q@mail.gmail.com' \
    --to=alistair23@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.