From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH] fs: Detect API misuse of i_op->lookup Date: Sun, 25 Jan 2015 22:16:43 +0000 Message-ID: <20150125221643.GK29656@ZenIV.linux.org.uk> References: <1422223060-8561-1-git-send-email-richard@nod.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Richard Weinberger Return-path: Content-Disposition: inline In-Reply-To: <1422223060-8561-1-git-send-email-richard@nod.at> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sun, Jan 25, 2015 at 10:57:40PM +0100, Richard Weinberger wrote: > Hunting down a refcount issue in an out-of-tree filesystem uncovered > that its lookup function directly returned the dentry which was passed to it. > Add a BUG_ON() to detect such misuse in future. In principle, it's not a bug. You *must* grab a reference to dentry before returning it, but you can very well decide to return the one you've got - any place where have ->lookup() return NULL has every right to become return dget(dentry).