Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: d76c769c8db4c ("pnfs/blocklayout: Don't add zero-length pnfs_block_dev")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

authored by

Zilin Guan and committed by
Trond Myklebust
5a74af51 0c728083

+4 -2
+4 -2
fs/nfs/blocklayout/dev.c
··· 417 417 d->map = bl_map_simple; 418 418 d->pr_key = v->scsi.pr_key; 419 419 420 - if (d->len == 0) 421 - return -ENODEV; 420 + if (d->len == 0) { 421 + error = -ENODEV; 422 + goto out_blkdev_put; 423 + } 422 424 423 425 ops = bdev->bd_disk->fops->pr_ops; 424 426 if (!ops) {