Re: [PATCH] comedi: comedi_bond: Fix leak of opened device references

From: Greg Kroah-Hartman

Date: Wed Nov 04 2026 - 08:04:54 EST


On Tue, Nov 03, 2026 at 05:36:10PM +0000, Ian Abbott wrote:
> bonding_attach() calls do_dev_config() to open other comedi devices
> specified by the user and tries to make use of them as part of the
> 'bonding' device. If it successfully opens the other device but cannot
> use it (either because it does not any subdevices of a type the
> 'bonding' device can use, or because of some error that occurs while
> dealing with its subdevices) then it is left in the open state and the
> fact that it is open does not get recorded by the 'bonding' device, so
> the reference to the opened device gets lost. Fix it by closing the
> opened device if it could not be bound to the 'bonding' device.
>
> To match previous behavior, if the opened device is unsuitable then
> ignore it (after closing it). The opened devices recorded by the
> 'bonding' device will eventually get closed by bonding_detach() even if
> bonding_attach() returns an error.
>
> Fixes: 3cf840f65ad5 ("Staging: comedi: add comedi_bond driver")
> Reported-by: Wentao Liang <vulab@xxxxxxxxxxx>

This is a known bot. I'll be glad to take this patch if you redo it
from you and that you take the authorship. As-is, I can't take it from
this fake "author", sorry.

greg k-h