Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5536279yba; Mon, 13 May 2019 12:36:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQNOGFFsI6VSWHsg0BHyEDQmCHGjfKVBNrFGHmR+sGjDPqiW/vdzuJ9TF6v40qTmGtHt3L X-Received: by 2002:a63:61cf:: with SMTP id v198mr33731344pgb.29.1557776173411; Mon, 13 May 2019 12:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557776173; cv=none; d=google.com; s=arc-20160816; b=ksmMkjFo4G6Vv4GtZDcZgeKTF6VnETtmTp3qYinZF4oBuZY1aMAuuhkQKGBEJQr+XF V63ZQnX91L2txWs2Np+JQEu9BoV9/ascYtivZT3H540H1qJtbOt2Jq0/4ZZ2H6JT8BB0 H4cp2cwlOYIIgVIKKaiBMSps/6+gBN6WMtP4+TvbdeS6xqfijo5bafNLCjhrkUu47e2H 9SAhp+zOdlkVCuarskpTlgARv7pyDsMe71JNBxZ1hPLhfhw2yyXJkhCqYTxMseAslH7i W1StcSS/0d+cXP/HTh9xtn+qlcBeegBgZDz9dWSuzXw8DpDTEvVRYRNg7pkIGGZ9h//e 5xdQ== 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:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=4beGpYbip4Qz5lzbEnBFrLSyp2Kmg69q5EgUSheO40A=; b=d5jja6HAvDTyeEzwElI/g/62kh/mpmQQHAr9b+vC4sQJ9K4xuNtsSV2lXq2ZOXNc7S XUy6Pgq+HQnuBG8v2S++6yHLugAp9EJzgCF7stgVMxKeE10ZpzG5UC9AmTcsbY3Nfe8s HT34/KJ+KoMIvPAtp5NJZafzfyFjJO8eo0x8Bqe8doWF3mm0OE203DEpSe3YkgBRXlwZ kKE9JRcEq5a4fCiM6wxP4AfRF3DtONhMwL1ZHsl6Mb9KMU3Cik03w3PInN3CvbAvRAyE BNozSchJFrN5DjiQOeuBaqU+WedQ19324Kb/UYqPTKy8/VB0TogLW8Ad/swYRqoyx/Az F28Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m19si18201926pgb.427.2019.05.13.12.35.56; Mon, 13 May 2019 12:36:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730105AbfEMRqJ (ORCPT + 99 others); Mon, 13 May 2019 13:46:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:45552 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726669AbfEMRqI (ORCPT ); Mon, 13 May 2019 13:46:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F09E5AD33; Mon, 13 May 2019 17:46:06 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id B1104DA851; Mon, 13 May 2019 19:47:07 +0200 (CEST) Date: Mon, 13 May 2019 19:47:07 +0200 From: David Sterba To: "Tobin C. Harding" Cc: Chris Mason , Josef Bacik , David Sterba , Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] Fix kobject error path memleaks Message-ID: <20190513174707.GH3138@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, "Tobin C. Harding" , Chris Mason , Josef Bacik , David Sterba , Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190513033912.3436-1-tobin@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190513033912.3436-1-tobin@kernel.org> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 13, 2019 at 01:39:10PM +1000, Tobin C. Harding wrote: > Is it ok to send patches during the merge window? Yes (depends on subsystem), the feedback for patches that are not fixes could be delayed after the merge window closes. > Applies on top of > Linus' mainline tag: v5.1, happy to rebase if there are conflicts. > > While auditing kobject_init_and_add() calls throughout the kernel it was > found that btrfs potentially has a couple of memleaks in the error path > code for kobject_init_and_add(). > > Failing calls to kobject_init_and_add() should be followed by a call to > kobject_put() since kobject_init_and_add() always calls kobject_init(). > > Of note, adding kobject_put() causes the release method to be called if > kobject_init_and_add() fails. For patch #1 this means we don't have to > manually free the space_info or call percpu_counter_destroy() since > these are both done by the release method. In the second patch, I > believe the added call to kobject_put() fits in with the fs_devices > lifecycle assumptions of open_ctree() but please could you review since > I am new to this code. We use the cleanup-after-error pattern where it's up to the callee to clean up, so it's right to do it like as you did. Patches added to the queue that's for 5.2-rcX. Thanks.