The following commit has been merged into the perf/core branch of tip: Commit-ID: 7c2bae2d9c27a89280b63ff3567d2dac2d89db28 Gitweb: https://git.kernel.org/tip/7c2bae2d9c27a89280b63ff3567d2dac2d89db28 Author: Andrii Nakryiko <andrii@xxxxxxxxxx> AuthorDate: Thu, 01 Aug 2024 15:27:19 +02:00 Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx> CommitterDate: Fri, 02 Aug 2024 11:30:31 +02:00 uprobes: simplify error handling for alloc_uprobe() Return -ENOMEM instead of NULL, which makes caller's error handling just a touch simpler. Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx> Reviewed-by: "Masami Hiramatsu (Google)" <mhiramat@xxxxxxxxxx> Reviewed-by: Jiri Olsa <jolsa@xxxxxxxxxx> Link: https://lore.kernel.org/r/20240801132719.GA8788@xxxxxxxxxx --- kernel/events/uprobes.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 698bb22..e9b092a 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -725,7 +725,7 @@ static struct uprobe *alloc_uprobe(struct inode *inode, loff_t offset, uprobe = kzalloc(sizeof(struct uprobe), GFP_KERNEL); if (!uprobe) - return NULL; + return ERR_PTR(-ENOMEM); uprobe->inode = inode; uprobe->offset = offset; @@ -1167,8 +1167,6 @@ static int __uprobe_register(struct inode *inode, loff_t offset, retry: uprobe = alloc_uprobe(inode, offset, ref_ctr_offset); - if (!uprobe) - return -ENOMEM; if (IS_ERR(uprobe)) return PTR_ERR(uprobe);