Re: [PATCH] RDMA/core: fix a NULL-pointer dereference in hw_stat_device_show()

From: Roman Gushchin
Date: Tue Feb 25 2025 - 22:37:18 EST


On Tue, Feb 25, 2025 at 09:16:18AM -0400, Jason Gunthorpe wrote:
> On Tue, Feb 25, 2025 at 03:42:28AM +0000, Roman Gushchin wrote:
>
> > diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> > index 0ded91f056f3..6998907fc779 100644
> > --- a/drivers/infiniband/core/device.c
> > +++ b/drivers/infiniband/core/device.c
> > @@ -956,6 +956,7 @@ static int add_one_compat_dev(struct ib_device *device,
> > ret = device_add(&cdev->dev);
> > if (ret)
> > goto add_err;
> > + device->groups[2] = NULL;
> > ret = ib_setup_port_attrs(cdev);
> > if (ret)
> > goto port_err;
>
> That's horrible - but OK, maybe something like that..
>
> Does it work? Or does the driver core need groups after the initial
> setup?
>
> Could we have two group lists and link them together? IIRC there was a
> way to do that without creating a sub directory

It does work.

I just sent a decent implementation of this idea, please, take a look.

Thank you!