Commit 5a74af51 authored by Zilin Guan's avatar Zilin Guan Committed by Trond Myklebust
Browse files

pnfs/blocklayout: Fix memory leak in bl_parse_scsi()



In bl_parse_scsi(), if the block device length is zero, the function
returns immediately without releasing the file reference obtained via
bl_open_path(), leading to a memory leak.

Fix this by jumping to the out_blkdev_put label to ensure the file
reference is properly released.

Fixes: d76c769c ("pnfs/blocklayout: Don't add zero-length pnfs_block_dev")
Signed-off-by: default avatarZilin Guan <zilin@seu.edu.cn>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 0c728083
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -417,8 +417,10 @@ bl_parse_scsi(struct nfs_server *server, struct pnfs_block_dev *d,
	d->map = bl_map_simple;
	d->pr_key = v->scsi.pr_key;

	if (d->len == 0)
		return -ENODEV;
	if (d->len == 0) {
		error = -ENODEV;
		goto out_blkdev_put;
	}

	ops = bdev->bd_disk->fops->pr_ops;
	if (!ops) {