mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 07:03:28 -04:00
misc: vmc_vmci: Fix potential memory leak in vmci_event_subscribe()
The memory allocated for struct vmci_subscription (sub) is not freed
in the error path when have_new_id is false. Fix that by adding a
kfree() call, and moving the read of sub->id to a point before freeing.
Fixes: 1d990201f9 ("VMCI: event handling implementation.")
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Acked-by: Vishnu Dasa <vishnu.dasa@broadcom.com>
Link: https://patch.msgid.link/20260722101215.76680-1-nihaal@cse.iitm.ac.in
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d9e81c7199
commit
210854a96e
@@ -179,16 +179,16 @@ int vmci_event_subscribe(u32 event,
|
||||
}
|
||||
}
|
||||
|
||||
*new_subscription_id = sub->id;
|
||||
if (have_new_id) {
|
||||
list_add_rcu(&sub->node, &subscriber_array[event]);
|
||||
retval = VMCI_SUCCESS;
|
||||
} else {
|
||||
kfree(sub);
|
||||
retval = VMCI_ERROR_NO_RESOURCES;
|
||||
}
|
||||
|
||||
mutex_unlock(&subscriber_mutex);
|
||||
|
||||
*new_subscription_id = sub->id;
|
||||
return retval;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vmci_event_subscribe);
|
||||
|
||||
Reference in New Issue
Block a user