Skip to content

Commit 5a74af5

Browse files
GoodLuck612Trond Myklebust
authored andcommitted
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: d76c769 ("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>
1 parent 0c72808 commit 5a74af5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

fs/nfs/blocklayout/dev.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,10 @@ bl_parse_scsi(struct nfs_server *server, struct pnfs_block_dev *d,
417417
d->map = bl_map_simple;
418418
d->pr_key = v->scsi.pr_key;
419419

420-
if (d->len == 0)
421-
return -ENODEV;
420+
if (d->len == 0) {
421+
error = -ENODEV;
422+
goto out_blkdev_put;
423+
}
422424

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

0 commit comments

Comments
 (0)