Re: [PATCH perf/core 1/4] uprobes: simplify session consumer tracking

From: Andrii Nakryiko
Date: Fri Dec 06 2024 - 12:51:00 EST


On Fri, Dec 6, 2024 at 6:07 AM Jiri Olsa <olsajiri@xxxxxxxxx> wrote:
>
> On Thu, Dec 05, 2024 at 04:24:14PM -0800, Andrii Nakryiko wrote:
>
> SNIP
>
> > static struct return_instance *alloc_return_instance(void)
> > {
> > struct return_instance *ri;
> >
> > - ri = kzalloc(ri_size(DEF_CNT), GFP_KERNEL);
> > + ri = kzalloc(sizeof(*ri), GFP_KERNEL);
> > if (!ri)
> > return ZERO_SIZE_PTR;
> >
> > - ri->consumers_cnt = DEF_CNT;
> > return ri;
> > }
> >
> > static struct return_instance *dup_return_instance(struct return_instance *old)
> > {
> > - size_t size = ri_size(old->consumers_cnt);
> > + struct return_instance *ri;
> > +
> > + ri = kmemdup(old, sizeof(*ri), GFP_KERNEL);
>
> missing ri == NULL check
>

Doh, of course, sorry, my stupid mistake. I'll send a follow up fix.

> jirka
>
> > +
> > + if (unlikely(old->cons_cnt > 1)) {
> > + ri->extra_consumers = kmemdup(old->extra_consumers,
> > + sizeof(ri->extra_consumers[0]) * (old->cons_cnt - 1),
> > + GFP_KERNEL);
> > + if (!ri->extra_consumers) {
> > + kfree(ri);
> > + return NULL;
> > + }
> > + }
> >
> > - return kmemdup(old, size, GFP_KERNEL);
> > + return ri;
> > }
> >
> > static int dup_utask(struct task_struct *t, struct uprobe_task *o_utask)
> > @@ -2369,25 +2372,28 @@ static struct uprobe *find_active_uprobe_rcu(unsigned long bp_vaddr, int *is_swb
> > return uprobe;
> > }
> >
> > -static struct return_instance*
>
> SNIP