On 2021/12/21 19:15, Christoph Hellwig wrote: >>> I think we can apply this patch as-is... >> >> With the patch as-is we'll still leak disk->ev if device_add fails. >> Something like the patch below should solve that by moving the disk->ev >> allocation later and always cleaning it up through disk->release: > > Sorry, this still had the extra return. > OK. Since blkdev_get_no_open() from blkdev_get_by_dev() returns NULL until disk_alloc_events() after device_add() completes, there is no race window for unbalanced disk_block_events(disk)/disk_unblock_events(disk) pair. Your patch seems to work. Please propose as a patch.