Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4712644yba; Sun, 12 May 2019 20:39:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbiGJw6+p9nrie1nzNLEgIOWmtTcstUFmaYbGDe2/fL6b8zGNPnsqkGtWVjtcmjDBTsuuS X-Received: by 2002:a17:902:201:: with SMTP id 1mr10016698plc.89.1557718769088; Sun, 12 May 2019 20:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557718769; cv=none; d=google.com; s=arc-20160816; b=FwUhIs1besqzGl/N2auhHd2NLWT8V1U4+6omkpQKQGG6B9RGJmrIjwHlcWI/XBF4t2 1bxdLvPiapSNMCIsjK7HVmMvCG0Yv+jILMudJSg1QoJ8ShfEoKiLhGjmDQka7/yFIm5S 8l2gQE/hGxd7EvTPmMYWjspTEtD8h7PCpWOlnnCJan+ji9V5xL+QG243xkSZOdIOvDWS NBgcDJ2U9rlXFqfc7ewnOeiEUyb4th8wrH0DWOEQRhVotKgoKO5iTkNgp/3vsJNMQs44 u99eE/ZPyJd5rDp4qhLd9RmK4xtSmqbqS7K2JGwENzpE10EGIogKALiKfnt660dBFaTq mVCQ== 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=IWWUUKQi6OBmjXErFSkhIaMM+KOX6vf11cpQeCEFglA=; b=NyEA93gwp7Omt85LDrx3Aq4vtelq0dLyAl8qnBwnCHYBkuCpGFmyRH4b4ofKC+AYo3 4HJIf1TPwv3vhs4d1I4RTzuKSiugSbrbETO1xt/lgZm5a9zQyPqAXSWfy4HgqjSJcIxg bwnDn+6wQaXjj80IJGiZ60pcBsBhMAeTm9hscSWtoPBwuYJZ/tfg5p1U+eJWGyTunOZy qQKYKthCL1c1UTxAgFIG70/piRD9Jy4YLobfk+sk0OWnM2La2FJTZeuhUQxFwMEDEZGg xaiKicUCkZ1G859Ezu55jIupntBfJDipowavc26c7Vrue5b7qND0n5Jhmbn7+1PvJEdY yzPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Ri2ZQRsE; 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 bh3si14281852plb.284.2019.05.12.20.39.12; Sun, 12 May 2019 20:39:29 -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=Ri2ZQRsE; 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 S1727478AbfEMDfu (ORCPT + 99 others); Sun, 12 May 2019 23:35:50 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:55163 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbfEMDfu (ORCPT ); Sun, 12 May 2019 23:35:50 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 4FF9422136; Sun, 12 May 2019 23:35:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 12 May 2019 23:35:49 -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=IWWUUKQi6OBmjXErF SkhIaMM+KOX6vf11cpQeCEFglA=; b=Ri2ZQRsEcQiG9fdh2dbALeoFQejH9F8ev 6C/KPORarnj5gSQECfmKJgc9Myzm/FzA0ZDd4NHzhB8NJtQPOTfISM+U6XTDx8eO w4zEBxStlzJNVEwKOnzbg8gMk4poS+ChVhPSt8jvYJkurTybx4ovBsJydQtEWZ06 /pHUJIPtFsP2lKxnfLX1YGeAig8WM4p+5llpLGh5SQnpQGP2VK1LXj3LFsEP0hV0 jJjST7syJIqDBs4Q1M3xj5HrrhE2Rrj+eNN0mGNdJvNaimBFPy+wx7oyvhT/WpPC IjFatASHFWKHK5zCJC76c6fiJeZf3FHYXkq/fa3jgC90HqHWATpGw== 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 66DB08005C; Sun, 12 May 2019 23:35:46 -0400 (EDT) From: "Tobin C. Harding" To: Mark Fasheh , Joel Becker , Greg Kroah-Hartman , "Rafael J. Wysocki" , ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org Cc: "Tobin C. Harding" Subject: [PATCH] ocfs2: Fix error path kobject memory leak Date: Mon, 13 May 2019 13:34:58 +1000 Message-Id: <20190513033458.2824-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 If a call to kobject_init_and_add() fails we should call kobject_put() otherwise we leak memory. Add call to kobject_put() in the error path of call to kobject_init_and_add(). Please note, this has the side effect that the release method is called if kobject_init_and_add() fails. Signed-off-by: Tobin C. Harding --- 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. thanks, Tobin. fs/ocfs2/filecheck.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c index f65f2b2f594d..1906cc962c4d 100644 --- a/fs/ocfs2/filecheck.c +++ b/fs/ocfs2/filecheck.c @@ -193,6 +193,7 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb) ret = kobject_init_and_add(&entry->fs_kobj, &ocfs2_ktype_filecheck, NULL, "filecheck"); if (ret) { + kobject_put(&entry->fs_kobj); kfree(fcheck); return ret; } -- 2.21.0