aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorAndy Adamson <andros@netapp.com>2011-06-13 18:36:17 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-06-15 11:24:30 -0400
commitcec765cf5891c7fc3d905832b481bfb6fd55825d (patch)
treeae3ec9371f7aedfcebb96a02887d5550c4ba5e26 /fs/nfs
parent533eb4611c9eea53072eb6a61d5a6393b6a77ed7 (diff)
NFSv4.1: allow zero fh array in filelayout decode layout
Signed-off-by: Andy Adamson <andros@netapp.com> cc:stable@kernel.org [2.6.39] Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs4filelayout.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 426908809c97..5d6f369b15d0 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -552,13 +552,18 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
552 __func__, nfl_util, fl->num_fh, fl->first_stripe_index, 552 __func__, nfl_util, fl->num_fh, fl->first_stripe_index,
553 fl->pattern_offset); 553 fl->pattern_offset);
554 554
555 if (!fl->num_fh) 555 /* Note that a zero value for num_fh is legal for STRIPE_SPARSE.
556 * Futher checking is done in filelayout_check_layout */
557 if (fl->num_fh < 0 || fl->num_fh >
558 max(NFS4_PNFS_MAX_STRIPE_CNT, NFS4_PNFS_MAX_MULTI_CNT))
556 goto out_err; 559 goto out_err;
557 560
558 fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *), 561 if (fl->num_fh > 0) {
559 gfp_flags); 562 fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *),
560 if (!fl->fh_array) 563 gfp_flags);
561 goto out_err; 564 if (!fl->fh_array)
565 goto out_err;
566 }
562 567
563 for (i = 0; i < fl->num_fh; i++) { 568 for (i = 0; i < fl->num_fh; i++) {
564 /* Do we want to use a mempool here? */ 569 /* Do we want to use a mempool here? */