Re: [PATCH] modpost: release allocation when early return no suffix .o in read_symbols()
Nathan Chancellor <[email protected]> Tue, 16 Jun 2026 21:21:52 -0700
| Newsgroups | dev.linux.lists.linux-kernel-mentees,org.kernel.vger.linux-kbuild,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <178167011232.2064238.5669414796099955471.b4-review@b4> |
On Wed, 10 Jun 2026 12:25:50 +0700, Robertus Diawan Chris <[email protected]> wrote: > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index abbcd3fc1394..8e231544f9f3 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -1585,6 +1585,7 @@ static void read_symbols(const char *modname) > > if (!strends(modname, ".o")) { > error("%s: filename must be suffixed with .o\n", modname); > + parse_elf_finish(&info); > return; > } > Thanks for the patch! While this change appears to be correct, would moving the strends() if block before the parse_elf() one resolve this as well? I think I would prefer going that route because neither check really depends on the other and we have to think less about unwinding with the checks flipped. Furthermore, modpost is a relatively short running host utility, so I don't really think it is worth optimizing for resource leaks like this. -- Cheers, Nathan