[PATCH 1/1] cmd/extension: avoid NULL pointer dereference
Kory Maincent
kory.maincent at bootlin.com
Mon Nov 17 15:05:18 CET 2025
On Mon, 17 Nov 2025 10:00:01 +0100
Kory Maincent <kory.maincent at bootlin.com> wrote:
> On Sun, 16 Nov 2025 12:41:53 +0100
> Heinrich Schuchardt <heinrich.schuchardt at canonical.com> wrote:
>
> > extension_get_list() will return NULL if there is no extension device.
> > Check for this situation.
> >
> > Addresses-Coverity-ID: 638557 - Null pointer dereferences (NULL_RETURNS)
> > Fixes: 2d12958ee71b ("boot: Remove legacy extension board support")
> > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
>
> Hello Heinrich, I have already sent a fix for this. Sorry I forgot to add you
> in Cc.
> https://patchwork.ozlabs.org/project/uboot/patch/20251112130742.97473-1-kory.maincent@bootlin.com/
>
> Your patch is better as it adds a custom log in case of no extension_list.
We will take your patch. This avoids writing a v2 for mine ;)
Acked-by: Kory Maincent <kory.maincent at bootlin.com>
Thank you!
>
> > ---
> > cmd/extension_board.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/cmd/extension_board.c b/cmd/extension_board.c
> > index 86e4795ba8a..75358abf666 100644
> > --- a/cmd/extension_board.c
> > +++ b/cmd/extension_board.c
> > @@ -99,6 +99,10 @@ static int do_extension_list(struct cmd_tbl *cmdtp, int
> > flag, int i = 0;
> >
> > extension_list = extension_get_list();
> > + if (!extension_list) {
> > + printf("No extension device\n");
> > + return CMD_RET_FAILURE;
> > + }
> > if (!alist_get_ptr(extension_list, 0)) {
> > printf("No extension registered - Please run \"extension
> > scan\"\n"); return CMD_RET_SUCCESS;
>
>
>
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
More information about the U-Boot
mailing list