[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CY5PR11MB636694A9C7A086AF584B7CDDED4FA@CY5PR11MB6366.namprd11.prod.outlook.com>
Date: Mon, 7 Jul 2025 07:08:33 +0000
From: "Usyskin, Alexander" <alexander.usyskin@...el.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC: "Abliyev, Reuven" <reuven.abliyev@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [char-misc-next v2] mei: bus: fix device leak
> Subject: Re: [char-misc-next v2] mei: bus: fix device leak
>
> On Mon, Jun 30, 2025 at 11:27:14AM +0000, Usyskin, Alexander wrote:
> > > Subject: Re: [char-misc-next v2] mei: bus: fix device leak
> > >
> > > On Mon, Jun 30, 2025 at 10:52:08AM +0000, Usyskin, Alexander wrote:
> > > > > Subject: Re: [char-misc-next v2] mei: bus: fix device leak
> > > > >
> > > > > On Tue, Jun 24, 2025 at 02:05:20PM +0300, Alexander Usyskin wrote:
> > > > > > The bus rescan function creates bus devices for all clients.
> > > > > > The fixup routine is executed on all devices, unneeded
> > > > > > devices are removed and fully initialized once set
> > > > > > is_added flag to 1.
> > > > >
> > > > > I don't understand why the mei bus is so special that it has to have
> > > > > this type of flag, when no other bus has that for its devices. The bus
> > > > > code should know if the device has been properly added or not, if not,
> > > > > then no release function can be called and the structure isn't even
> > > > > viable to be used or touched at all.
> > > > >
> > > > > So why is this needed?
> > > >
> > > > It seems that is_added can be replaced by device_is_registered().
> > >
> > > Again, why do you need to track that?
> > >
> > > But yes, that should work, although using it is usually a sign that
> > > something is a bit broken in the design.
> > >
> >
> > Mei bus uses device_initialize() and device_add() pair.
> > After device_initialize() there are different hooks and filters called,
> > that may lead to dropping the device or adding with device_add().
> > Thus, we should track if device_add() is called when destroying the device.
> > Not sure if this can be re-architected to use device_register().
>
> You don't need to use device_register() but perhaps stop it with the
> "rescan the bus and attempt to add all devices again" logic that is in
> mei_cl_bus_rescan()? There's no need to call device_add() on a device
> and then way later attempt to initialize it, right?
>
> Just find any new devices that you don't already have on your list of
> registered devices, and then only add/initialize them, should be a lot
> simpler logic overall than what the code is currently doing.
>
> greg k-h
This will require a big refactoring. I'll look how that can be done.
Meanwhile can this fix be merged on current codebase and
refactoring will be done separately?
- -
Thanks,
Sasha
Powered by blists - more mailing lists