Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp277793ybi; Wed, 29 May 2019 21:13:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqysYzwTXL3iP7HZyLqioA4QRNaW0pP3zdf+ltcWPe7NifUQzmbGeHeHbdWb/IHOUxoeuCw/ X-Received: by 2002:a63:6b41:: with SMTP id g62mr1880357pgc.240.1559189627448; Wed, 29 May 2019 21:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189627; cv=none; d=google.com; s=arc-20160816; b=h9Tvsoq9Jrh6K6gOXc6cJzupKD5ntSVEngy68lFAsQL35NOrFLpD1sQ6nepsBu7W/i /yHJztO/X/A2zDVfvWB77nDe9p+IPxVl+ERkSTXO2pnhmemlpczCQ9pDx92+H09Jel+b Xj2xgnZyk8lhyKfs9+RqLfXoJth/9K26uMO5/4BKbzYuc1ThtZ/AG0ctxVKv+4y4Kl8/ cj4T7+V/TEHMNFIv7Eg8NQ0PSFGTfZp05nKFDSZA/CAG4EiuJanzBF6TDFWu8fDIZzva CLql3dLL6F2iefnDwFMWXu10ii1eidf+csVBwJmNq6P9QadsN+Ygge6Y7wJpPmRuiigW KJEA== 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=4HA9leM0ztKAFzm+pz+KmLhDFhRQl8ikEkzbEyQww0w=; b=G6QDHIN0s/Na2q7jTjH55hNblOe1vDouxKMIbvC3NGJOzg9Afdyz58uhMG7v/Wx+vW LUziFZzSZ0MWRBNzoGOLJFH065Eq9ERbMkJ/YeoGR9/EBYitpfQWrnX8KRnckbLTJUIM alhiyQ2iaMloFWjcTCZXcYDffgSz/lKCgmJsM/bPfA/QKgH9tcpykocgZgCd7adp0nQZ DrJMQiJYdOXX04NN6yQAxhoCARxt8z5PWT8clVvM89MBz75zIzR4PM19C9KYkIjUTSuX IW6SZ/EfoUQsgBmdZlz2k0B+VD18M1BF97biH24ETEo14WQVUs8MjQ6uwM6oAfGdDtrI frvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cqb29i+m; 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 d75si2238214pfm.259.2019.05.29.21.13.31; Wed, 29 May 2019 21:13:47 -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=Cqb29i+m; 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 S1731110AbfE3EMZ (ORCPT + 99 others); Thu, 30 May 2019 00:12:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:43280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730742AbfE3DQi (ORCPT ); Wed, 29 May 2019 23:16:38 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 34F7124610; Thu, 30 May 2019 03:16:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186198; bh=OaoAOkH9zU15rVyt0mmICzWn2QwLipVk6jU0vzMqr6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cqb29i+mQQjKINCYHSVbV5+JpQmxZMHrk84bkoA619Yz5Kmd/0Z3nnuedNWK29d+2 L7T4vzoR33Pvo+PlSpIOwxAgWLkggW7dHbiL+C+vGZ58IHa583lWnIsnGGo0ogqKg9 5hnqO1hWw8EFG1Ko3FoMvZRsG4bE2UtJLR7kbO3o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Tobin C. Harding" , Linus Torvalds , Peter Zijlstra , "Rafael J. Wysocki" , Thomas Gleixner , Vincent Guittot , Viresh Kumar , Ingo Molnar , Sasha Levin Subject: [PATCH 4.19 074/276] sched/cpufreq: Fix kobject memleak Date: Wed, 29 May 2019 20:03:52 -0700 Message-Id: <20190530030531.038844861@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@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 9a4f26cc98d81b67ecc23b890c28e2df324e29f3 ] Currently the error return path from kobject_init_and_add() is not followed by a call to kobject_put() - which means we are leaking the kobject. Fix it by adding a call to kobject_put() in the error path of kobject_init_and_add(). Signed-off-by: Tobin C. Harding Cc: Greg Kroah-Hartman Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Thomas Gleixner Cc: Tobin C. Harding Cc: Vincent Guittot Cc: Viresh Kumar Link: http://lkml.kernel.org/r/20190430001144.24890-1-tobin@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq.c | 1 + drivers/cpufreq/cpufreq_governor.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 505c9a55d5551..d3213594d1a7a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1103,6 +1103,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) cpufreq_global_kobject, "policy%u", cpu); if (ret) { pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret); + kobject_put(&policy->kobj); goto err_free_real_cpus; } diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 6d53f7d9fc7a9..69fc5cf4782fb 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -459,6 +459,8 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy) /* Failure, so roll back. */ pr_err("initialization failed (dbs_data kobject init error %d)\n", ret); + kobject_put(&dbs_data->attr_set.kobj); + policy->governor_data = NULL; if (!have_governor_per_policy()) -- 2.20.1