From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1E10C072B1 for ; Thu, 30 May 2019 03:56:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97F8324EB4 for ; Thu, 30 May 2019 03:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559188614; bh=RJUoL8bQeWAxpSivfC7e8hx2HKVwItkI2lzjMojlw7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=WrY+KGaEDmOrkBarx2G7mzX9Wj2SzLhfVdFhPda1R/qaJNqu617h40lOHdiO0pb54 x2uC+7NkfnYDOgU6tD1HK24ReUe5drX27KMSb3Q1JsPPaLixyoSmCy5AyMOCijC1Sf mBXsd874g3qJ+txSTz6Tf0JS08KOMsGTwSfUh+mQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731746AbfE3DS4 (ORCPT ); Wed, 29 May 2019 23:18:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:53070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728891AbfE3DSz (ORCPT ); Wed, 29 May 2019 23:18:55 -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 6CF39247F0; Thu, 30 May 2019 03:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186334; bh=RJUoL8bQeWAxpSivfC7e8hx2HKVwItkI2lzjMojlw7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kouHhwLYOsHheIZ9HDwdMdMbzm2eucM1Q7F/Q9n5mUn9Q9tI9UdyZcaizAFnaU+4o CAW3E8/o3RfYQTB2plVfyPmUf3pncxK3MTvdnjGlt7VY7EtY2qKDANTtkgDpsuOEGq z643DGy8ndR9Y+LSTc7hZqBmK5W8j6ZhF3Cq4YiQ= 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.14 055/193] sched/cpufreq: Fix kobject memleak Date: Wed, 29 May 2019 20:05:09 -0700 Message-Id: <20190530030457.195546437@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030446.953835040@linuxfoundation.org> References: <20190530030446.953835040@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 9f5c51cd67ad9..fceb18d26db8e 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1101,6 +1101,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 6a16d22bc6043..146237aab395d 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