From patchwork Mon Jun 13 22:22:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 876652 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5DMMhvA029584 for ; Mon, 13 Jun 2011 22:22:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753922Ab1FMWWm (ORCPT ); Mon, 13 Jun 2011 18:22:42 -0400 Received: from mx2.netapp.com ([216.240.18.37]:1473 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752193Ab1FMWWm (ORCPT ); Mon, 13 Jun 2011 18:22:42 -0400 X-IronPort-AV: E=Sophos;i="4.65,360,1304319600"; d="scan'208";a="555271725" Received: from smtp1.corp.netapp.com ([10.57.156.124]) by mx2-out.netapp.com with ESMTP; 13 Jun 2011 15:22:41 -0700 Received: from localhost.localdomain (orca.hq.netapp.com [10.55.72.67] (may be forged)) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id p5DMMfWl016535; Mon, 13 Jun 2011 15:22:41 -0700 (PDT) From: andros@netapp.com To: trond.myklebust@netapp.com Cc: linux-nfs@vger.kernel.org, Andy Adamson Subject: [PATCH Bakeathon version 2 1/2] NFSv4.1: allow zero fh array in filelayout decode layout Date: Mon, 13 Jun 2011 18:22:37 -0400 Message-Id: <1308003758-2075-1-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.6.6 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 13 Jun 2011 22:22:43 +0000 (UTC) From: Andy Adamson Signed-off-by: Andy Adamson cc:stable@kernel.org [2.6.39] --- fs/nfs/nfs4filelayout.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c index 2cfeaeb..f0414ee 100644 --- a/fs/nfs/nfs4filelayout.c +++ b/fs/nfs/nfs4filelayout.c @@ -551,13 +551,18 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo, __func__, nfl_util, fl->num_fh, fl->first_stripe_index, fl->pattern_offset); - if (!fl->num_fh) + /* Note that a zero value for num_fh is legal for STRIPE_SPARSE. + * Futher checking is done in filelayout_check_layout */ + if (fl->num_fh < 0 || fl->num_fh > + max(NFS4_PNFS_MAX_STRIPE_CNT, NFS4_PNFS_MAX_MULTI_CNT)) goto out_err; - fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *), - gfp_flags); - if (!fl->fh_array) - goto out_err; + if (fl->num_fh > 0) { + fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *), + gfp_flags); + if (!fl->fh_array) + goto out_err; + } for (i = 0; i < fl->num_fh; i++) { /* Do we want to use a mempool here? */