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,USER_AGENT_GIT autolearn=ham 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 C94A0C072B1 for ; Thu, 30 May 2019 04:32:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EE0D24320 for ; Thu, 30 May 2019 04:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559190750; bh=5swxMja5Nw/UI7DIPlC+uLffq4UKDWG1SuSP92uN7T8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PaQk08tZCOvYdBal61OsDH7W849Vg6sOm5ixH1Iaj/25OKZM+IGZhaeqpmoCyZA1v 65k03ZcGNGiajheRp6TMSvrhJgEgysCeC3+nNlkOm68/CyvnUSdycWOZ0GU/vaTjJa n4Gma+eDWPOiPSEDTkpPOv1noD+PNlMvddwvaU6k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729608AbfE3Ec3 (ORCPT ); Thu, 30 May 2019 00:32:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727794AbfE3DNg (ORCPT ); Wed, 29 May 2019 23:13:36 -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 AEBE724534; Thu, 30 May 2019 03:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186015; bh=5swxMja5Nw/UI7DIPlC+uLffq4UKDWG1SuSP92uN7T8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zQ5P3qJyneKQyBplDXX7DYwyPNpTq9LZdkLeMcoPjjjgTDRACaZVW4raaqD0ce0ab 1P+i2jn3WH8YKFBVS6p8uC7NoovqQFUB73JIV5Z+y9Orye9c7ffpVEthfh18mzrlDM /YFThDlS7eZKobqZBRqAeZYLIb6wqcr8Sb0oEGcs= 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 5.0 081/346] sched/cpufreq: Fix kobject memleak Date: Wed, 29 May 2019 20:02:34 -0700 Message-Id: <20190530030545.240930828@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.363386121@linuxfoundation.org> References: <20190530030540.363386121@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 ef0e33e21b988..97b094963253d 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 ffa9adeaba31b..9d1d9bf02710b 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