Re: [PATCH] [net-next] net/mlx5e: xsk: dynamically allocate mlx5e_channel_param

From: Arnd Bergmann
Date: Tue Jul 23 2019 - 07:29:46 EST


On Tue, Jul 23, 2019 at 1:21 PM Maxim Mikityanskiy <maximmi@xxxxxxxxxxxx> wrote:
> On 2019-07-08 18:16, Maxim Mikityanskiy wrote:
> > On 2019-07-08 15:55, Arnd Bergmann wrote:
> >> - mlx5e_build_xsk_cparam(priv, params, xsk, &cparam);
> >> + cparam = kzalloc(sizeof(*cparam), GFP_KERNEL);
> >
> > Similar code in mlx5e_open_channels (en_main.c) uses kvzalloc. Although
> > the struct is currently smaller than a page anyway, and there should be
> > no difference in behavior now, I suggest using the same alloc function
> > to keep code uniform.
> >
> >> /* Create a dedicated SQ for posting NOPs whenever we need an IRQ to be
> >> * triggered and NAPI to be called on the correct CPU.
> >> */
> >> - err = mlx5e_open_icosq(c, params, &cparam.icosq, &c->xskicosq);
> >> + err = mlx5e_open_icosq(c, params, &cparam->icosq, &c->xskicosq);
> >> if (unlikely(err))
> >> goto err_close_icocq;
> >>
> >
> > Here is kfree missing. It's a memory leak in the good path.
>
> Arnd, I'm going to take over your patch and respin it, addressing my own
> comments, because it's been quite a while, and we want to have this fix.
>
> Thanks for spotting it.

Thanks for taking care of it now. I was planning to do a respin, but
the reply got lost in the depth of my inbox so I forgot about it.

Arnd