uprobes: Guard against kmemdup() failing in dup_return_instance()

If kmemdup() failed to alloc memory, don't proceed with extra_consumers
copy.

Fixes: e62f2d4927 ("uprobes: Simplify session consumer tracking")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20241206183436.968068-1-andrii@kernel.org
This commit is contained in:
Andrii Nakryiko 2024-12-06 10:34:36 -08:00 committed by Ingo Molnar
parent d29e744c71
commit 02c56362a7

View File

@ -2048,6 +2048,8 @@ static struct return_instance *dup_return_instance(struct return_instance *old)
struct return_instance *ri;
ri = kmemdup(old, sizeof(*ri), GFP_KERNEL);
if (!ri)
return NULL;
if (unlikely(old->cons_cnt > 1)) {
ri->extra_consumers = kmemdup(old->extra_consumers,