Re: [PATCH v2] module: fix lost error code from codetag_load_module()

From: Hao Ge

Date: Tue Sep 08 2026 - 06:54:16 EST


Hi Daniel


On 2026/9/8 03:42, Daniel Gomez wrote:
>
>
> On 2026-08-27T11:05:03+08:00, Hao Ge <hao.ge@xxxxxxxxx> wrote:
>> If codetag_load_module() fails, err is not set to reflect the failure
>> and load_module() returns 0 after the module has been torn down.
>>
>> Also, if the module is a livepatch, mod->klp_info allocated by
>> copy_module_elf() leaks on this error path. Free it via a new
>> livepatch_cleanup label.
>>
>> Fixes: 044d2aee6c57 ("alloc_tag: handle module codetag load errors as module load failures")
>> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
>> Suggested-by: Petr Pavlu <petr.pavlu@xxxxxxxx>
>> Reviewed-by: Bradley Morgan <brads@xxxxxxxxxxxxxx>
>> Cc: stable@xxxxxxxxxxxxxxx
>> Signed-off-by: Hao Ge <hao.ge@xxxxxxxxx>
>
> We need the unwind from codetag_unload_module() as reported by sashiko.
>

Thanks for you review.

I skipped it because alloc_tag is the only codetag type and it
already cleans up after itself.

With a second codetag type the problem Sashiko reported could indeed
be triggered.

My thinking at the time was to do it in codetag itself, as a separate patch,
since it feels odd to unload something whose load just failed.

Happy to hear your thoughts on this.

Thanks
Best Regards
Hao

> With that,
>
> Reviewed-by: Daniel Gomez <da.gomez@xxxxxxxxxxx>
>
>