Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4713777yba; Sun, 12 May 2019 20:41:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwo3yfSTtozoGnYl2ddsWevqNJkkiI6v2zsu5S/Bisj0FesjHt//UDdd1epo4uB2HPPrDAi X-Received: by 2002:a17:902:108a:: with SMTP id c10mr28495512pla.48.1557718891085; Sun, 12 May 2019 20:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557718891; cv=none; d=google.com; s=arc-20160816; b=keE6vZzTN3dfGG1L0HNhmHdQRtHIOLXXFgPT6ue7wURyAa/5GCAwt222IolzciKp63 4q9IKlUwcEP9IGlkC2Y/ex1meqFjYYRf+CVzf5z/zCdUz0AoxnMgNOI/FGlvsuGpLFTX PA5QPyuvQg/GcNrQsURtFs1tedwWG8PAQPm3XdF14Fbu4NCNRqvszKCuu2xKBROF+Nqd IB77d6n6puFzoI+5P+EakqaOX+i4gh9rEyii6O4+ERr7fcgYnI0nfIhmkIN319OcDJ0L vsf+m3/GXpNCPBDMAwpKsQK54V9VVt/6y6Sd6i95DXsxFt5ijK9d+oR9oV5nz0xqVR1A 96Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2FlEJdf2fi3fJ5B4NRVr7xTzZV11Nurruym7Rqoj6sE=; b=h6+wgIjB99H1WolV8Lh5B2XT/l8SVs8GmvmZ4EL1rLDh4/7wddRuseGmCjtM4/qMS4 xs4ObaafZ7AcgAiohsn+wlPrllADkKYTzv2F64j4TG0EBnafLZIjewaV5hVAW53DhsE+ kIOy8BJuBZ2Mlhcs/57a74PDY1bQRTFXplmHy9/YxD5RA+auprWkZAnj5OKuQ6nUzhCx cg4ZDEb7i5pAzQkCjAlOkSltYSSr0tHzVUdTjX8wkilhslm5i2wMXhzsOvGGHjjcvLgF qFou66aWOTOGLgNw5vuvBukxB1d7FrTY1d+lL6KUJJhl5CqzWYJsSWjQFjrNDWj8CJn9 nAFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=EQlQ7R49; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v83si14802670pgb.461.2019.05.12.20.41.14; Sun, 12 May 2019 20:41:31 -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; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=EQlQ7R49; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727526AbfEMDkU (ORCPT + 99 others); Sun, 12 May 2019 23:40:20 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:51421 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbfEMDkU (ORCPT ); Sun, 12 May 2019 23:40:20 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 072F7221AD; Sun, 12 May 2019 23:40:19 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 12 May 2019 23:40:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=2FlEJdf2fi3fJ5B4N RVr7xTzZV11Nurruym7Rqoj6sE=; b=EQlQ7R49I/nSEGF9TKzS4iTWhGsFwsJN8 oNkPN7E7hed7HHnSRABYN17LKtv9T1oEFNtTJUJyovG8BaslPSK8Hsk/2KaYGwdE vORNsRanDIEU3+5LMR1vpGl10hkFJZPkRTqZAqnkBuwet2G14PTQqLm6KYUMfzJq xJj5XVqkSi3htu4E7B8CkvGO60GGId9VGMrt3cgy4rYmpSzLgmt9INvvQdNXSJA2 rZljskz4V+7JRCazGKGd+WkpVnB50iSyeKqZomDsSpl07xzQKaYZjgLjbCA+/9wd jKfkLJj61/G4SN9rEh+HQHFGXx30zIIRCP94M6TZHc50pUXLpY36w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrleefgdejudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhnucev rdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkphepud dvgedrudeiledrudeirddukeehnecurfgrrhgrmhepmhgrihhlfhhrohhmpehtohgsihhn sehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from eros.localdomain (124-169-16-185.dyn.iinet.net.au [124.169.16.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 285B08005C; Sun, 12 May 2019 23:40:14 -0400 (EDT) From: "Tobin C. Harding" To: Chris Mason , Josef Bacik , David Sterba Cc: "Tobin C. Harding" , Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/2] Fix kobject error path memleaks Date: Mon, 13 May 2019 13:39:10 +1000 Message-Id: <20190513033912.3436-1-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Is it ok to send patches during the merge window? 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. CC'ing the kobject maintainers/reviewers also. Thanks, Tobin. Tobin C. Harding (2): fs: btrfs: Fix error path kobject memory leak fs: btrfs: Don't leak memory when failing add fsid fs/btrfs/extent-tree.c | 3 +-- fs/btrfs/sysfs.c | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) -- 2.21.0