From patchwork Wed Oct 31 08:05:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ycnian@gmail.com X-Patchwork-Id: 1676511 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3E7833FC36 for ; Wed, 31 Oct 2012 08:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754063Ab2JaIOv (ORCPT ); Wed, 31 Oct 2012 04:14:51 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:63711 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752158Ab2JaIOt (ORCPT ); Wed, 31 Oct 2012 04:14:49 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so804717pbb.19 for ; Wed, 31 Oct 2012 01:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=lmeJgxCi3lHKNbD0o2uH6m5DSUOk1LvRivb8kxm5Vpo=; b=bypsb24BDztwcyP40sRHJlEsM0ZvNeERdcWALYsUctJbVf6fgcI3IGCgYbWCzhz4Jf LW1G+/SPndHJA7vfNWW/DpLnQjvccp9sRn7Qd+Ps8bCWUC2+MbTLB22OwU7w4V/ogtkF p1mbgEZQ9bDnofkw7yOsw29TwZwDsg/fQTJT6qOcJe603rGpu4MRTift1dJHgEGnPZs1 tL+v/TUpJEzD5Dxuu2QzWQW8MZgOusUxezX3jWRihQrDC7u6L5eRFTkw1VaYeLqn26t4 f67Ps1bzTWZVLT/Nu44yMmeCYxBKsCFoGMTBAXeVztfHSTIsksILYETbShgvxqgpPnJd XKkg== Received: by 10.66.78.67 with SMTP id z3mr74446812paw.33.1351671288536; Wed, 31 Oct 2012 01:14:48 -0700 (PDT) Received: from localhost ([159.226.5.131]) by mx.google.com with ESMTPS id j9sm1822909pav.15.2012.10.31.01.14.46 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Oct 2012 01:14:47 -0700 (PDT) From: ycnian@gmail.com To: Trond.Myklebust@netapp.com Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Yanchuan Nian Subject: [PATCH] nfs: Check whether a layout pointer is NULL before free it Date: Wed, 31 Oct 2012 16:05:48 +0800 Message-Id: <1351670748-21927-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 From: Yanchuan Nian The new layout pointer in pnfs_find_alloc_layout() may be NULL because of out of memory. we must do some check work, otherwise pnfs_free_layout_hdr() will go wrong because it can not deal with a NULL pointer. Signed-off-by: Yanchuan Nian --- fs/nfs/pnfs.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index fe624c9..2878f97 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -925,8 +925,8 @@ pnfs_find_alloc_layout(struct inode *ino, if (likely(nfsi->layout == NULL)) { /* Won the race? */ nfsi->layout = new; return new; - } - pnfs_free_layout_hdr(new); + } else if (new != NULL) + pnfs_free_layout_hdr(new); out_existing: pnfs_get_layout_hdr(nfsi->layout); return nfsi->layout;