Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5975527yba; Wed, 1 May 2019 03:45:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeiif/W33sypvLSYwMXNFLOC1WnBjYFJa/PMwy72pjygCWcVaYqlP2ZFq9PCAoznK4GCe4 X-Received: by 2002:a63:314a:: with SMTP id x71mr24178509pgx.385.1556707541370; Wed, 01 May 2019 03:45:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556707541; cv=none; d=google.com; s=arc-20160816; b=Te4l3Fvh+DD+VeKi38LR7fyo8NKT/EcaLdgjVXYRujbcOzExfA+Fxf/z00Vvn2/1DD 3DtkyMzEfzgPqA9XrBTTv/heVHundyG1cmCUbuC0aEd3BBO0Lg5rsJcTV/TBKZ8dNUF3 AGKsyTdYzjCK2lRAarNPnfcqoEif/6tJGaiyMEsU8/E7pO27TZeRqLc/I/ngI+Kme55x l3ZmZq6TZOL0jgxkFS/+kqcuenSzEEFueKUK9rnqrZ1JcTB7Z3V7K53mNDhtK5TtdC+T r0oGF96FCwCBY0Ur/gYHuLOABHRKz0778+74I6Nz3JhSDpA3WD1j+v2WpIMJIqaxosD6 xJtg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6jIDot9q+ETcjJ81c/CwKJHm0202giWvzTzLoa6BM0g=; b=q3eSrSPCvHeTorliZtYHXEoYMIvsVjg+UCqp5qLBvBGEncZ15vk/w6L9ews9U5LrfZ JR+5bnPMjn7aT7hdeXoM5FxAoMn6IfRsNs9FOJOIjbiauC5MeMgaAmI8Qw4FajVS5Wq9 Rk0NmKgRySIuQScsFMRE1m80W4psFA8ueNC1YcyF3IvsP66HbhcWJeo2glja2Xc3O8bS 92L0tRT9NrGQKxcUKuNi8E4A5S+K+771FAdnrZiAGdWf57lYZLuCdPjFyk9C3u6RjEgX rAeGTz+OS1WF81RolNVJO09mg4ScpyT6LpYVDDirwtxl36tWe/EU9w3MppX4BAA2r7W9 v/GQ== ARC-Authentication-Results: i=1; mx.google.com; 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 f13si8609442pfh.82.2019.05.01.03.45.26; Wed, 01 May 2019 03:45:41 -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; 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 S1726341AbfEAKoS (ORCPT + 99 others); Wed, 1 May 2019 06:44:18 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:52866 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbfEAKoR (ORCPT ); Wed, 1 May 2019 06:44:17 -0400 Received: from 79.184.254.69.ipv4.supernova.orange.pl (79.184.254.69) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.213) id 5fa0b5174c139008; Wed, 1 May 2019 12:44:15 +0200 From: "Rafael J. Wysocki" To: Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , tobin@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cpufreq: Fix kobject memleak Date: Wed, 01 May 2019 12:44:15 +0200 Message-ID: <1632168.ncxJcclsFx@kreacher> In-Reply-To: <815f7c7cea02e05c90d5bf678ea8717f01cc9f63.1556604312.git.viresh.kumar@linaro.org> References: <815f7c7cea02e05c90d5bf678ea8717f01cc9f63.1556604312.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, April 30, 2019 8:05:52 AM CEST Viresh Kumar wrote: > 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: Viresh Kumar > --- > Tobin fixed this for schedutil already. > > 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 e10922709d13..bbf79544d0ad 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -1098,6 +1098,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 ffa9adeaba31..9d1d9bf02710 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()) > Applied, thanks!