[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025071601-squatter-lent-4260@gregkh>
Date: Wed, 16 Jul 2025 11:54:26 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Alexander Usyskin <alexander.usyskin@...el.com>
Cc: Reuven Abliyev <reuven.abliyev@...el.com>, linux-kernel@...r.kernel.org
Subject: Re: [char-misc-next v3 2/5] mei: make char device control its own
lifetime
On Wed, Jul 09, 2025 at 06:13:41PM +0300, Alexander Usyskin wrote:
> Allocate character device dynamically and allow to
> control its own lifetime as it may outlive mei_device
> structure while character device closes after parent
> device is removed from the system.
>
> Signed-off-by: Alexander Usyskin <alexander.usyskin@...el.com>
> ---
> drivers/misc/mei/main.c | 36 +++++++++++++++++++++++-------------
> drivers/misc/mei/mei_dev.h | 4 ++--
> 2 files changed, 25 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
> index 95d4c1d8e4e6..5335cf39d663 100644
> --- a/drivers/misc/mei/main.c
> +++ b/drivers/misc/mei/main.c
> @@ -51,7 +51,9 @@ static int mei_open(struct inode *inode, struct file *file)
>
> int err;
>
> - dev = container_of(inode->i_cdev, struct mei_device, cdev);
> + dev = idr_find(&mei_idr, iminor(inode));
What keeps the device structure in this idr after it has been removed
from the system before the char device is closed? Does the class device
lifespan outlive this? It seems like it really isn't saved anywhere,
but the release function accesses it, right?
Or is that a _different_ device pointer? How many different
pointers/structures are associated with a struct mei_device now?
confused,
greg k-h
Powered by blists - more mailing lists