Re: [PATCH v2 00/34] Open block devices as files

Christian Brauner
2024-02-06T16:10:43Z

> > Can you double-check what's in vfs.super right now? I thought I fixed
> > this up. I'll check too!
>
> Well, you've fixed the "double allocation" issue but there's still a
> problem that you do:
>
> int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder,
> const struct blk_holder_ops *hops, struct file *bdev_file)
> {
> ...
> handle = kmalloc(sizeof(struct bdev_handle), GFP_KERNEL);
> if (!handle)
> return -ENOMEM;
> if (holder) {
> mode |= BLK_OPEN_EXCL;
> ret = bd_prepare_to_claim(bdev, holder, hops);
> if (ret)
> return ret;
> } else {
> ...
>
>
> So in case bd_prepare_to_claim() fails we forget to free the allocated
> handle.

Grumble grumble grumble, thank you! Fixing.