From patchwork Mon Mar 11 00:29:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ycnian@gmail.com X-Patchwork-Id: 2246101 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 84173DF24C for ; Mon, 11 Mar 2013 00:41:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753496Ab3CKAlk (ORCPT ); Sun, 10 Mar 2013 20:41:40 -0400 Received: from mail-pb0-f43.google.com ([209.85.160.43]:42106 "EHLO mail-pb0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753467Ab3CKAlj (ORCPT ); Sun, 10 Mar 2013 20:41:39 -0400 Received: by mail-pb0-f43.google.com with SMTP id md12so3134847pbc.16 for ; Sun, 10 Mar 2013 17:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=dho5n3tOyBOBGt6zvYYq8yPdNjVB9qQ/edF4LHrUOCI=; b=QqBcbq8p/NX/ths0IKMij3OwN6S8yRIZbTJazvv6eWki1Wz2XMqNajqxxm+L+OJZZk APWc1YA0YkQyMZd7AjMA8VEXyzmRzEErLthgixh7GpUKmipmwqaeyUw11Rpm8JQIXtjr kF36FpUoklbzEFtHcC6jgB+xlxNN6LMoj+KLg8Xb4U8uq6tHdEcZmnBfTbyovLIvP0gz u5uoxcpRiZ/NSzFRAaEcVXtWL+pSrt01a7JgL5TMHLyTiG8C8r8QboKuUlQB7Fml9iKN ioehFBpl1plGv8RwI4gP7F/eIdGnqMrA/V7grvy+6pRYkmyBcLkt5CiCoYOt5N7dc958 WURw== X-Received: by 10.68.232.72 with SMTP id tm8mr16137408pbc.108.1362962498870; Sun, 10 Mar 2013 17:41:38 -0700 (PDT) Received: from localhost ([159.226.5.132]) by mx.google.com with ESMTPS id rl3sm17667330pbb.28.2013.03.10.17.41.36 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Sun, 10 Mar 2013 17:41:37 -0700 (PDT) From: ycnian@gmail.com To: bfields@fieldses.org Cc: linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH] nfsd: fix bug on nfs4 stateid deallocation Date: Mon, 11 Mar 2013 08:29:46 +0800 Message-Id: <1362961786-4452-1-git-send-email-ycnian@gmail.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 NFS4_OO_PURGE_CLOSE is not handled properly. To avoid memory leak, nfs4 stateid which is pointed by oo_last_closed_stid is freed in nfsd4_close(), but NFS4_OO_PURGE_CLOSE isn't cleared meanwhile. So the stateid released in THIS close procedure may be freed immediately in the coming encoding function. --- fs/nfsd/nfs4state.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 75c873d..7499c91 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3850,6 +3850,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfsd4_close_open_stateid(stp); release_last_closed_stateid(oo); + oo->oo_flags &= ~NFS4_OO_PURGE_CLOSE; oo->oo_last_closed_stid = stp; if (list_empty(&oo->oo_owner.so_stateids)) {