Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1616764ybh; Thu, 16 Jul 2020 18:04:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBJABXBwuK582t/G5cfWBeACb8zFqR0R8Zm2OPbLzkonjTmJSRj/6vX4yVTnZAfsN8ZWoO X-Received: by 2002:a17:907:376:: with SMTP id rs22mr6705405ejb.47.1594947846270; Thu, 16 Jul 2020 18:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594947846; cv=none; d=google.com; s=arc-20160816; b=W2A9BKl4tULEzlKx/v6mzV4XfS0UTwZU+BlHR25huB37PTxW37JS2BKR1Pm4Lyaw+V s22PLFEufmHW67nTlo8B+6XUEF8qSwzEDW1XmepLvthkeb0mxJQeSe/C/IM779sNhksk 3ZpjE9oKbNUxCVHb7GYhcOccj8hs+loUjWXH6VLFlu1Rwcg70DoyQjyYKfa45/rnZX1w j7tc3/Z8z8i0T7gjj4rCMLQdyc2V84OaFS9Wl2hH2cmxWa7jgIWoR4JQBuVZz5AT7G7v YfoNHTqX8YRk/TFLOWRTuvS42N+UKb57tk9MIDxytfyDmXMBM6mbuVTWqj1kTzKmMY5V Z/Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter; bh=l3rhI4MTdeiyfRGfcR2UTl0gzps4A2swHO+u3w7tkpE=; b=IQR7ywaGdf6pJiwjrDzqzU7gDdv/lCcFhfhyIUDNESu1L/1r+2P0WLvpAVFnCp0btY 55pNPiOWxCE8yVVOcLIJoXNdO3dplDh6c8AoCmTxsxw9qJBPlUz668RPyIGG0RuYlgYH sOS0ikFzkiEdYwh+etbRPTAX0rFUwe83/LNMePb/i3LKBnEQV3KHFS11I75fdBP0tCbf 8VKRKUu4PVd/vOWwhfmz2lpzHq35z4cJwNHTB6sDG0yeXyoeZPfTvgo38JzcdxS7JQIN WFMxDyxNibUm48ETELMILqj/QhCDcM47r5br40PzSAiI1KW4I4md4Kf/4/HIetFQBjly gynQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=GFOklXWK; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bv8si4079290ejb.476.2020.07.16.18.03.05; Thu, 16 Jul 2020 18:04:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=GFOklXWK; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726238AbgGQBDC (ORCPT + 99 others); Thu, 16 Jul 2020 21:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbgGQBDC (ORCPT ); Thu, 16 Jul 2020 21:03:02 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D5BC061755 for ; Thu, 16 Jul 2020 18:03:02 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 47ACB9C61; Thu, 16 Jul 2020 21:03:01 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 47ACB9C61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1594947781; bh=l3rhI4MTdeiyfRGfcR2UTl0gzps4A2swHO+u3w7tkpE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GFOklXWKDGepyv6HP2z52JLLhKQmsWrPgnoz9qW4yDHuC1gd2CUT32QtSzjxlNUWX BCbNM8Osd5Tq4ViKCRTZac18wF3yiOUPBXsa9fSEUQgkIreiMFKwXDSYNbFpa/jfsQ Sz5BAU2Ag/zmu1YALt1aUjuxPWWlMwH3yJAVlIvY= Date: Thu, 16 Jul 2020 21:03:01 -0400 From: "J. Bruce Fields" To: NeilBrown Cc: Jeff Layton , linux-nfs@vger.kernel.org Subject: Re: nfs4_show_superblock considered harmful :-) Message-ID: <20200717010301.GC18568@fieldses.org> References: <871rn38suc.fsf@notabene.neil.brown.name> <20200529220608.GA22758@fieldses.org> <87a71n7dek.fsf@notabene.neil.brown.name> <20200715185456.GE15543@fieldses.org> <20200716171958.GB18568@fieldses.org> <87tuy7vxeb.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87tuy7vxeb.fsf@notabene.neil.brown.name> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Jul 17, 2020 at 09:43:40AM +1000, NeilBrown wrote: > On Thu, Jul 16 2020, J. Bruce Fields wrote: > > --- a/fs/nfsd/nfs4state.c > > +++ b/fs/nfsd/nfs4state.c > > @@ -507,6 +507,16 @@ find_any_file(struct nfs4_file *f) > > return ret; > > } > > > > +static struct nfsd_file *find_deleg_file(struct nfs4_file *f) > > +{ > > + struct nfsd_file *ret; > > + > > + spin_lock(&f->fi_lock); > > + ret = nfsd_file_get(f->fi_deleg_file); > > A test on f->fi_deleg_file being non-NULL would make this look safer. > It would also make the subsequent test on the return value appear sane. Yes, thanks!-b. diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c2a2e56c896d..6e8811e7c134 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -509,10 +509,11 @@ find_any_file(struct nfs4_file *f) static struct nfsd_file *find_deleg_file(struct nfs4_file *f) { - struct nfsd_file *ret; + struct nfsd_file *ret = NULL; spin_lock(&f->fi_lock); - ret = nfsd_file_get(f->fi_deleg_file); + if (f->fi_deleg_file) + ret = nfsd_file_get(f->fi_deleg_file); spin_unlock(&f->fi_lock); return ret; }