Closed he7850 closed 2 years ago
I think you're right that the two checks are redundant.
The only way I see object->funcs can be NULL is if patch_init() fails to allocate memory for an instance of lobject->funcs. In that case I don't think there would be a memory leak if patch_free_livepatch() broke out of the loop early because all the subsequent objects in 'patch->objs' would already have NULL funcs and relocs.
So I don't see a memory leak, but you're welcome to submit a pull request to get rid of the redundancy.
@jpoimboe Thanks for your answer. I have submitted a PR.
https://github.com/dynup/kpatch/blob/1ca8e8fc1fa34751a5c7067b82a8319958680a60/kmod/patch/livepatch-patch-hook.c#L230-L247 Is the for loop condition 'object->funcs' in livepatch-patch-hook.c#L235 neccessary?