grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 04/21] dl: provide a fake grub_dl_set_persistent for the e


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATCH v1 04/21] dl: provide a fake grub_dl_set_persistent for the emu target
Date: Sat, 4 Jan 2025 21:36:56 +0300

grub-emu has 2 modes: full with all modules compiled-in and lite with
actual module loading (mostly useful for testing module loading
itself.
So just adding if (mod) ... is going to fix all cases and avoids ifdef

On Wed, Dec 18, 2024 at 5:58 PM Sudhakar Kuppusamy
<sudhakar@linux.ibm.com> wrote:
>
> From: Daniel Axtens <dja@axtens.net>
>
> Trying to start grub-emu with a module that calls grub_dl_set_persistent
> will crash because grub-emu fakes modules and passes NULL to the module
> init function.
>
> Provide an empty function for the emu case.
>
> Fixes: ee7808e2197c (dl: Add support for persistent modules)
> Signed-off-by: Daniel Axtens <dja@axtens.net>
> Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
> ---
>  include/grub/dl.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/include/grub/dl.h b/include/grub/dl.h
> index 750fc8d3d..fb4476797 100644
> --- a/include/grub/dl.h
> +++ b/include/grub/dl.h
> @@ -242,11 +242,22 @@ grub_dl_get (const char *name)
>    return 0;
>  }
>
> +#ifdef GRUB_MACHINE_EMU
> +/*
> + * Under grub-emu, modules are faked and NULL is passed to GRUB_MOD_INIT.
> + * So we fake this out to avoid a NULL deref.
> + */
> +static inline void
> +grub_dl_set_persistent (grub_dl_t mod __attribute__((unused)))
> +{
> +}
> +#else
>  static inline void
>  grub_dl_set_persistent (grub_dl_t mod)
>  {
>    mod->persistent = 1;
>  }
> +#endif
>
>  static inline int
>  grub_dl_is_persistent (grub_dl_t mod)
> --
> 2.43.5
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



-- 
Regards
Vladimir 'phcoder' Serbinenko



reply via email to

[Prev in Thread] Current Thread [Next in Thread]