Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2232348ybi; Thu, 20 Jun 2019 11:17:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/b1AFfjeyPQhn/rTmXC9yXGmYLKOQjMv2Sr7z726Rv0bQvSoMOfMNt4rY6WXuaQhniU7g X-Received: by 2002:a65:6495:: with SMTP id e21mr13763180pgv.383.1561054647956; Thu, 20 Jun 2019 11:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561054647; cv=none; d=google.com; s=arc-20160816; b=JH1Wulg4hqzi2ALH8VmBwwZeaSx/AQhAECHsX59x7ANbYTOTbYw5KdkiQjaZ7D/Aov 6V/TuDdgHgEf5R0ojVN9EIj6XZBNTtmwEX2f41t5DVn/Ul0W7DlsHH60f2EHydZAFmfc 263R8BlmffTrgvzPE5VpMY9pvTWizjdgRyRBuF1mDuNZYZiyd0yxOqc3fgVskpoLsZQ+ ywsihGa2q6MtZHM4FDLIL9ECRzmx12y8HN155DsU7emR0H2/2d98hJl+CwxLVSMIurGw E+KuuM3D2DbY5+lyS1TKTD8KHCkO2FIJXUHiqclTCSacAJw4IwYkJQqEV9tDYvpSu6nP kXSg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YV1p/ItcEKpfzuGpIt1dXW1eLju0zWiHFFrZ9Ys5X6s=; b=LIlX4Ipm2xZ9u/38rcqNIZOd4wyy1E7yR8ieM+mSH0RAUOvkkGjOVUFLIIuG3Z4Rbh ehSqBS2+SYlBOOVlUZNDaBtyYGcHxeB/+OiNmlKhPYXrySqd2Pwcn42DGw9EOQAnmQtP Tygd03CTqG0B6ct9TQdhbVmu7+qmfXbD8nfzMYxaJf3bWv/kGSH4W2pa48N1vFLlGzFZ 83UbISCAu6tmuuFi5+l1vCOR8UglzAI0mnL32LYtCCibrFBudZm5M6JtRj7naAAkf+yS Dzgwsq2hJSGDuW8CLu2HMY+4aeWExHHcTjy5s7PpEZ2DQ9bP6gSCf7BwoZ/s4ldaybnS raRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CzXs7zCk; 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 n1si331377pld.115.2019.06.20.11.17.13; Thu, 20 Jun 2019 11:17:27 -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=@kernel.org header.s=default header.b=CzXs7zCk; 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 S1729532AbfFTSRJ (ORCPT + 99 others); Thu, 20 Jun 2019 14:17:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:46318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729556AbfFTSRE (ORCPT ); Thu, 20 Jun 2019 14:17:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB55E2084E; Thu, 20 Jun 2019 18:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054623; bh=LCuOsWiv7WF+Oe5V31rsGOh6q0ch6ErTxkreM7dz9f8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CzXs7zCk0s/KU6LcdVxIXTZby33LdUkp0mkSdQ6XH9U6la0OMQ1XSzIwWV+onk859 pRqUKZdigz0HmVLrbWJgHhxAhPUDq+pxD4evNhjspTwMESHnU5O6aksz7X2ML/SR8L mVVjrdMqlzu1e747q+CN5FIM5nqwd3AEIWIDfKGc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Tobin C. Harding" , Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Gang He , Jun Piao , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.1 93/98] ocfs2: fix error path kobject memory leak Date: Thu, 20 Jun 2019 19:58:00 +0200 Message-Id: <20190620174354.065965164@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174349.443386789@linuxfoundation.org> References: <20190620174349.443386789@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit b9fba67b3806e21b98bd5a98dc3921a8e9b42d61 ] 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. Link: http://lkml.kernel.org/r/20190513033458.2824-1-tobin@kernel.org Signed-off-by: Tobin C. Harding Reviewed-by: Greg Kroah-Hartman Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Gang He Cc: Jun Piao Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- 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.20.1