From: Oleg Drokin Subject: Re: Leak in nlmsvc_testlock for async GETFL case Date: Mon, 03 Dec 2007 12:49:41 -0500 Message-ID: <672CF125-6078-45DB-821A-294DA30A4526@Sun.COM> References: <48611B2F-1587-48C5-9F30-8DCFA1121CF6@Sun.COM> <74C1E9BE-0A67-4957-B254-789F0821E669@sgi.com> Mime-Version: 1.0 Content-Type: text/plain; delsp=yes; format=flowed; charset=US-ASCII Content-Transfer-Encoding: 7BIT Cc: "J. Bruce Fields" , linux-fsdevel@vger.kernel.org To: Felix Blyakher Return-path: Received: from brmea-mail-1.Sun.COM ([192.18.98.31]:56313 "EHLO brmea-mail-1.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbXLCRto (ORCPT ); Mon, 3 Dec 2007 12:49:44 -0500 Received: from fe-amer-09.sun.com ([192.18.109.79]) by brmea-mail-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id lB3Hnhr7002594 for ; Mon, 3 Dec 2007 17:49:43 GMT Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0JSH00K01ILC8400@mail-amer.sun.com> (original mail from Oleg.Drokin@Sun.COM) for linux-fsdevel@vger.kernel.org; Mon, 03 Dec 2007 10:49:43 -0700 (MST) In-reply-to: <74C1E9BE-0A67-4957-B254-789F0821E669@sgi.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hello! On Dec 3, 2007, at 12:00 PM, Felix Blyakher wrote: >> Per our discussion, I am resending this patch that fixes a leak >> in nlmsvc_testlock. >> It is addition to another leak fixing patch you already have. >> Without the patch, there is a leakage of nlmblock structure >> refcount that holds a >> reference nlmfile structure, that holds a reference to struct >> file, when async GETFL >> is used (-EINPROGRESS return from file_ops->lock()), and also in >> some error cases. > > @@ -502,15 +509,19 @@ > > } > > else { > > nlmsvc_unlink_block(block); > > - return nlm_granted; > > + ret = nlm_granted; > > + goto out; > > } > > Do we really need to release block with 'goto out' here? Yes, absolutely. > nlmsvc_unlink_block() is doing it internally in the following > call chain: ... > And on a last reference 'block' will be freed in nlmsvc_free_block. > Are you sure we have an extra reference here and won't go through > nlmsvc_free_block? It releases reference that was obtained when lock was linked into a queue by nlmsvc_insert_block (which is indicated by B_QUEUED flag in the nlmblock) And then we need to release another reference that we got from block lookup. This path you pointed out is definitely leaking, it is a success path for async GETFL handling so I tested this case. Bye, Oleg