[PATCH v2] x86/vm86: fix vm86 struct leak on copy_from_user() failure
From: fffsqian
Date: Wed Jun 24 2026 - 22:29:58 EST
Hi all,
This is v2 of the vm86 memory leak fix.
Changes since v1:
1. Drop the newly_allocated flag; use old_vm86 pointer comparison to decide when to free memory, taking advantage of kfree(NULL) safety.
2. Revert the unnecessary err variable type change to limit this patch to only the leak fix.
3. Convert all individual error returns to a single centralized goto cleanup path.
4. Fix cleanup ordering: free the new vm86 allocation first, then restore the original thread vm86 pointer to avoid state corruption.
Thanks to Boris for the review.
Qingshuang Fu