From patchwork Wed Jun 15 15:39:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 882512 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 p5FFe6E1021481 for ; Wed, 15 Jun 2011 15:40:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755169Ab1FOPkE (ORCPT ); Wed, 15 Jun 2011 11:40:04 -0400 Received: from mail-ew0-f46.google.com ([209.85.215.46]:64137 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755191Ab1FOPkD (ORCPT ); Wed, 15 Jun 2011 11:40:03 -0400 Received: by ewy4 with SMTP id 4so211690ewy.19 for ; Wed, 15 Jun 2011 08:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer; bh=JlFRZUVauWQTx0qofobwp62uUN6oWlxjKJSVq41nYVc=; b=cXExKD2oEwL78rwT30BKnVvBEZSBaRCxqmtlqz0YtPJU5JU/ih2GGg72iBtMkcCQjX zyibSsB6z/49BU76uV90/HStte4hZ+iuYDRMMlRsr1+W9Za2VuloEm7TYk13UAYcJepS Vx+ss0U6v04lSgZR20FsmRTUENTv/iaRt7jKE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=xGhi6BdCicnsYfIgSrduv1k3qOtWbN0fOUMHX1KUdah/N4Fnx6bfUD+cv/3gm2DO6o BP4nvx8sQupHShLuOLS2HnB8iwzIVFCc16d3XPUODGSOJ6BK6auECLNfe5rhQeLlae3X 91PcvjGw9CHkWcd+xPFj+i5bARoNQ1/OMrfwo= Received: by 10.213.101.8 with SMTP id a8mr465089ebo.15.1308152402008; Wed, 15 Jun 2011 08:40:02 -0700 (PDT) Received: from localhost.localdomain (tonian-2.citi.umich.edu [141.212.112.251]) by mx.google.com with ESMTPS id s11sm510114eef.1.2011.06.15.08.39.59 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 15 Jun 2011 08:40:01 -0700 (PDT) From: Benny Halevy To: trond.myklebust@netapp.com Cc: linux-nfs@vger.kernel.org, Benny Halevy Subject: [PATCH] NFSv4.1: need to put_layout_hdr on _pnfs_return_layout error path Date: Wed, 15 Jun 2011 11:39:57 -0400 Message-Id: <1308152397-16920-1-git-send-email-benny@tonian.com> X-Mailer: git-send-email 1.7.4.4 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]); Wed, 15 Jun 2011 15:40:06 +0000 (UTC) We always get a reference on the layout header and we rely on nfs4_layoutreturn_release to put it. If we hit an allocation error before starting the rpc proc we bail out early without dereferncing the layout header properly. Signed-off-by: Benny Halevy --- fs/nfs/nfs4proc.c | 1 + fs/nfs/pnfs.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 79f3c33..a4705bc 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5774,6 +5774,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) struct pnfs_layout_hdr *lo = NFS_I(lrp->args.inode)->layout; dprintk("--> %s\n", __func__); + dprintk("%s: ref %d\n", atonic_read(&lo->plh_refcount)); if (!nfs4_sequence_done(task, &lrp->res.seq_res)) return; diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 0feeccc..bc3eb74 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -675,6 +675,7 @@ _pnfs_return_layout(struct inode *ino) lrp = kzalloc(sizeof(*lrp), GFP_KERNEL); if (unlikely(lrp == NULL)) { status = -ENOMEM; + put_layout_hdr(lo); goto out; }