From patchwork Sat Jan 24 05:39:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 5698721 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0F4D09F4DC for ; Sat, 24 Jan 2015 05:39:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2CD612024C for ; Sat, 24 Jan 2015 05:39:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E068202E6 for ; Sat, 24 Jan 2015 05:39:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751279AbbAXFjk (ORCPT ); Sat, 24 Jan 2015 00:39:40 -0500 Received: from mail-ie0-f180.google.com ([209.85.223.180]:57814 "EHLO mail-ie0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751316AbbAXFjh (ORCPT ); Sat, 24 Jan 2015 00:39:37 -0500 Received: by mail-ie0-f180.google.com with SMTP id rl12so1047744iec.11 for ; Fri, 23 Jan 2015 21:39:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=meiFIGbiAfgoBl7ZYreyRF/SRjAy21uQMy4Lcad9fDg=; b=FSqaktthHaW9bQEGCkLK77RwiJgjBc5Dyy0+hEXeyOIreLkrYYmnSHDW0D3siTtxor haGBsCwlGF4rtPWMsbpuwz+VthLXOnpCwlqfN8VNffoAxRnjcJGH8mNY44djQuM721J+ U1QxLIPynoEOXuQv4xtM7Ja8zdj8KhlkrMW+13CmncvJt5JmBAMyK+zOELmI6HPtoPuk yi/lG8aaQkWYJ3c5ETrvJHl0JkXhIZV8gYh4yJo+podWy6Ht9x9iJNXftjncWn0cgP3/ i5MvB62ZcYHKCUA7c5k0/Z7MOxHPlZZA7nOgxn559GGl+PBGUVcAKogp8sXAoxEjjMDt I1UQ== X-Gm-Message-State: ALoCoQkTY/RLYs2moaGrZNqcZHTnJ6cSjBqulqPzTy+zQiLGOMyrx11aOMu/+w0Y1zg59P/lbYtb X-Received: by 10.42.100.199 with SMTP id b7mr11957549ico.36.1422077976978; Fri, 23 Jan 2015 21:39:36 -0800 (PST) Received: from leira.trondhjem.org.localdomain (c-68-40-185-14.hsd1.mi.comcast.net. [68.40.185.14]) by mx.google.com with ESMTPSA id 15sm2086694ioq.8.2015.01.23.21.39.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 21:39:36 -0800 (PST) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 4/5] NFSv4: Check for NULL argument in nfs_*_seqid() functions Date: Sat, 24 Jan 2015 00:39:27 -0500 Message-Id: <1422077968-116473-5-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422077968-116473-4-git-send-email-trond.myklebust@primarydata.com> References: <1422077968-116473-1-git-send-email-trond.myklebust@primarydata.com> <1422077968-116473-2-git-send-email-trond.myklebust@primarydata.com> <1422077968-116473-3-git-send-email-trond.myklebust@primarydata.com> <1422077968-116473-4-git-send-email-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Trond Myklebust --- fs/nfs/nfs4state.c | 21 ++++++++++++++------- fs/nfs/nfs4xdr.c | 5 ++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index b922e43d69b8..590f096fd011 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1015,7 +1015,7 @@ void nfs_release_seqid(struct nfs_seqid *seqid) { struct nfs_seqid_counter *sequence; - if (list_empty(&seqid->list)) + if (seqid == NULL || list_empty(&seqid->list)) return; sequence = seqid->sequence; spin_lock(&sequence->lock); @@ -1071,13 +1071,15 @@ static void nfs_increment_seqid(int status, struct nfs_seqid *seqid) void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid) { - struct nfs4_state_owner *sp = container_of(seqid->sequence, - struct nfs4_state_owner, so_seqid); - struct nfs_server *server = sp->so_server; + struct nfs4_state_owner *sp; + + if (seqid == NULL) + return; + sp = container_of(seqid->sequence, struct nfs4_state_owner, so_seqid); if (status == -NFS4ERR_BAD_SEQID) nfs4_drop_state_owner(sp); - if (!nfs4_has_session(server->nfs_client)) + if (!nfs4_has_session(sp->so_server->nfs_client)) nfs_increment_seqid(status, seqid); } @@ -1088,14 +1090,18 @@ void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid) */ void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid) { - nfs_increment_seqid(status, seqid); + if (seqid != NULL) + nfs_increment_seqid(status, seqid); } int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task) { - struct nfs_seqid_counter *sequence = seqid->sequence; + struct nfs_seqid_counter *sequence; int status = 0; + if (seqid == NULL) + goto out; + sequence = seqid->sequence; spin_lock(&sequence->lock); seqid->task = task; if (list_empty(&seqid->list)) @@ -1106,6 +1112,7 @@ int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task) status = -EAGAIN; unlock: spin_unlock(&sequence->lock); +out: return status; } diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 7e7be5ab70bb..d05fada4929c 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -946,7 +946,10 @@ static void encode_uint64(struct xdr_stream *xdr, u64 n) static void encode_nfs4_seqid(struct xdr_stream *xdr, const struct nfs_seqid *seqid) { - encode_uint32(xdr, seqid->sequence->counter); + if (seqid != NULL) + encode_uint32(xdr, seqid->sequence->counter); + else + encode_uint32(xdr, 0); } static void encode_compound_hdr(struct xdr_stream *xdr,