From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754903AbaKYLKb (ORCPT ); Tue, 25 Nov 2014 06:10:31 -0500 Received: from mail-ob0-f169.google.com ([209.85.214.169]:33889 "EHLO mail-ob0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754056AbaKYLKY (ORCPT ); Tue, 25 Nov 2014 06:10:24 -0500 MIME-Version: 1.0 In-Reply-To: <1416820083-20902-1-git-send-email-tomeu.vizoso@collabora.com> References: <1416820083-20902-1-git-send-email-tomeu.vizoso@collabora.com> Date: Tue, 25 Nov 2014 16:40:23 +0530 Message-ID: Subject: Re: [PATCH v2] cpufreq: Ref the policy object sooner From: Viresh Kumar To: Tomeu Vizoso Cc: "linux-pm@vger.kernel.org" , Javier Martinez Canillas , "Rafael J. Wysocki" , Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24 November 2014 at 14:38, Tomeu Vizoso wrote: > Do it before it's assigned to cpufreq_cpu_data, otherwise when a driver > tries to get the cpu frequency during initialization the policy kobj is > referenced and we get this warning: > > ------------[ cut here ]------------ > WARNING: CPU: 1 PID: 64 at include/linux/kref.h:47 kobject_get+0x64/0x70() > Modules linked in: > CPU: 1 PID: 64 Comm: irq/77-tegra-ac Not tainted 3.18.0-rc4-next-20141114ccu-00050-g3eff942 #326 > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0x98/0xd8) > [] (dump_stack) from [] (warn_slowpath_common+0x84/0xb4) > [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24) > [] (warn_slowpath_null) from [] (kobject_get+0x64/0x70) > [] (kobject_get) from [] (cpufreq_cpu_get+0x88/0xc8) > [] (cpufreq_cpu_get) from [] (cpufreq_get+0xc/0x64) > [] (cpufreq_get) from [] (actmon_thread_isr+0x134/0x198) > [] (actmon_thread_isr) from [] (irq_thread_fn+0x1c/0x40) > [] (irq_thread_fn) from [] (irq_thread+0x134/0x174) > [] (irq_thread) from [] (kthread+0xdc/0xf4) > [] (kthread) from [] (ret_from_fork+0x14/0x3c) > ---[ end trace b7bd64a81b340c59 ]--- > > Signed-off-by: Tomeu Vizoso > > --- > > v2: * Properly unwind when erroring out. > --- > drivers/cpufreq/cpufreq.c | 42 +++++++++++++++++++++--------------------- > 1 file changed, 21 insertions(+), 21 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 4473eba..ae27ea6 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -898,46 +898,31 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy, > struct freq_attr **drv_attr; > int ret = 0; > > - /* prepare interface data */ > - ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, > - &dev->kobj, "cpufreq"); > - if (ret) > - return ret; > - > /* set up files for this cpu device */ > drv_attr = cpufreq_driver->attr; > while ((drv_attr) && (*drv_attr)) { > ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); > if (ret) > - goto err_out_kobj_put; > + return ret; > drv_attr++; > } > if (cpufreq_driver->get) { > ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); > if (ret) > - goto err_out_kobj_put; > + return ret; > } > > ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); > if (ret) > - goto err_out_kobj_put; > + return ret; > > if (cpufreq_driver->bios_limit) { > ret = sysfs_create_file(&policy->kobj, &bios_limit.attr); > if (ret) > - goto err_out_kobj_put; > + return ret; > } We should add proper handling for error returned from sysfs_create_file() someday, but its obviously not what you are trying to fix. Acked-by: Viresh Kumar