lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aYOwKLWgNUvD1WVV@pc>
Date: Wed, 4 Feb 2026 21:46:32 +0100
From: Salah Triki <salah.triki@...il.com>
To: Ian Abbott <abbotti@....co.uk>
Cc: H Hartley Sweeten <hsweeten@...ionengravers.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] comedi: fix device lifecycle handling in
 comedi_dev_kref_release()

On Mon, Feb 02, 2026 at 03:12:29PM +0000, Ian Abbott wrote:
> On 02/02/2026 12:09, Ian Abbott wrote:
> > NAK
> > 
> > This isn't freeing the `struct device`, it is freeing the `struct
> > comedi_device`.  The `struct device` will be freed by
> > `device_create_release()` in "drivers/base/core.c".
> 
> To clarify, the call to `put_device()` from `comedi_dev_kref_release()`
> matches the call to `get_device()` after a successful call to
> `device_create()` from `comedi_alloc_board_minor()`.
> 
> The counterpart to `comedi_alloc_board_minor()` is `comedi_free_board_dev()`
> which calls `device_destroy()` (matching the call to `device_create()`),
> followed by a call to `comedi_dev_put()`. `comedi_dev_put()` will call
> `comedi_dev_kref_release()` via `kref_put()` when its reference count
> reaches zero, and as mentioned previously, its call to `put_device()`
> matches the previous call to `get_device()` after the device was created.
> So there are no hooks back to the comedi module code or the `struct
> comedi_device` at that point because the `struct device` has already been
> removed from the system.
> 
> The reason for the extra calls to `get_device()` and `put_device()` is
> explained by commit 8f988d8784e3 ("staging/comedi: keep reference to class
> device after destroyed").
> 
> -- 
> -=( Ian Abbott <abbotti@....co.uk> || MEV Ltd. is a company  )=-
> -=( registered in England & Wales.  Regd. number: 02862268.  )=-
> -=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
> -=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-

Thanks for the detailed explanation, that makes sense. I’ll drop this patch.

Best regards,
Salah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ