Commit e1c6cfbb authored by Trond Myklebust's avatar Trond Myklebust Committed by Anna Schumaker

pNFS/flexfiles: Check the layout validity in ff_layout_mirror_prepare_stats

Ensure that we check the layout pointer and validity after dereferencing
it in ff_layout_mirror_prepare_stats.

Fixes: 08e2e5bc ("pNFS/flexfiles: Clean up layoutstats")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent f6395572
...@@ -2520,9 +2520,9 @@ ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo, ...@@ -2520,9 +2520,9 @@ ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo,
return i; return i;
} }
static int static int ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args)
ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args)
{ {
struct pnfs_layout_hdr *lo;
struct nfs4_flexfile_layout *ff_layout; struct nfs4_flexfile_layout *ff_layout;
const int dev_count = PNFS_LAYOUTSTATS_MAXDEV; const int dev_count = PNFS_LAYOUTSTATS_MAXDEV;
...@@ -2533,11 +2533,14 @@ ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args) ...@@ -2533,11 +2533,14 @@ ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args)
return -ENOMEM; return -ENOMEM;
spin_lock(&args->inode->i_lock); spin_lock(&args->inode->i_lock);
ff_layout = FF_LAYOUT_FROM_HDR(NFS_I(args->inode)->layout); lo = NFS_I(args->inode)->layout;
args->num_dev = ff_layout_mirror_prepare_stats(&ff_layout->generic_hdr, if (lo && pnfs_layout_is_valid(lo)) {
&args->devinfo[0], ff_layout = FF_LAYOUT_FROM_HDR(lo);
dev_count, args->num_dev = ff_layout_mirror_prepare_stats(
NFS4_FF_OP_LAYOUTSTATS); &ff_layout->generic_hdr, &args->devinfo[0], dev_count,
NFS4_FF_OP_LAYOUTSTATS);
} else
args->num_dev = 0;
spin_unlock(&args->inode->i_lock); spin_unlock(&args->inode->i_lock);
if (!args->num_dev) { if (!args->num_dev) {
kfree(args->devinfo); kfree(args->devinfo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment