Received: by 10.213.65.68 with SMTP id h4csp2506019imn; Mon, 2 Apr 2018 08:46:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+UM3FCoFgn3avPgxzOdp6jfucpZ+3To8mAJc8lPRw5i6AKXBxNtZWjv0g5RajuJw1wPKS4 X-Received: by 10.99.127.82 with SMTP id p18mr6621163pgn.188.1522683995768; Mon, 02 Apr 2018 08:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522683995; cv=none; d=google.com; s=arc-20160816; b=FwC6iEzo7Of45lzWKT/Ff3qfCKNRr24hR+Y7Kn1g80H018OY3qcKBH8sgv3WqI1Hk5 4Hm4XAZ5ZM3lnFhAFEpLNS9KCDW+Lc0A+4I5bUN4t/dHkK3XUrbW9Cxkn4WwINbKv87l uz3UrMUovn6Cn37WeC3we/pWlR4MF0HocWIJ7/6SEc9xmUK9r6E2J3vWjJICsUbWuN2/ 9iz16O7Tqsu0ht7s/SXLsupqWPEcQ+lcOoV6Ul8cbO+1hf2aLypDnfcnGXMRyKY2KRPV OXKKJF1911Cw8mpDWzWL2nivVnwypO8mrNrFfe8YqUKQiQa4KBnrEhQANahayYExTSG1 s9Ug== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Ji3mkogIQmo4c4IrWZKrtTGnCsMfljAsrEoOEPoQ278=; b=glSKcEkKPWl4pA+96yjAbl/GVEjcUBfb54hxQ6LbVhoOeMdU0RjQD1k4ixvTqoX7po WemAFahnc+Xl+MvIVGKuichPOuec8QgioZjWs9RvpxpHl0MnIq+T53s/N9aLvIaWVlUk 1UNbohPnYSK0VBjNvYr4rxSDwHuriHtgAScMbdPGoBDgB5SqvHibrKz8siq0XDah5tbY B1rp6J8qxY5yBu/Zpb775sWY77kjJsN+pIfx+4XRoZEagFmi81lWraBM0+jiOVFk8g3e jWuRAvo/5X8ALchc2nfKE4mJtqG54QlgTOsAfSoQA5VAZR6uptTdqegegwS6ywvUlKj1 QKpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=N8dL01nA; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t80si369928pgb.686.2018.04.02.08.46.20; Mon, 02 Apr 2018 08:46:35 -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=@ti.com header.s=ti-com-17Q1 header.b=N8dL01nA; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752530AbeDBPpN (ORCPT + 99 others); Mon, 2 Apr 2018 11:45:13 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:18874 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751990AbeDBPpL (ORCPT ); Mon, 2 Apr 2018 11:45:11 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w32Fj8wa013156; Mon, 2 Apr 2018 10:45:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1522683908; bh=ZcZF7j7rkPG9pSG+5+0qtGQ7j3VEegXv7lMaS2p2YtA=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=N8dL01nAwBspYzPnaKzZVPiu3ue30C6gwRq2/bQBhy41oaJGw6yvLNH8zdI6dxr4E eQc5joNqu6RZVyO2eYRSxcwWZGAx7qlpBjjlWnCIZDWguo/K7p4NdkmxX8o+ZnOzN/ i2fuaZdC19OAep+F/A3KVke1SW86zQohUQVZ6o8Y= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w32Fj7cU003177; Mon, 2 Apr 2018 10:45:08 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Mon, 2 Apr 2018 10:45:07 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Mon, 2 Apr 2018 10:45:07 -0500 Received: from [128.247.58.153] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w32Fj7ws030712; Mon, 2 Apr 2018 10:45:07 -0500 Subject: Re: [PATCH] cpufreq: ti-cpufreq: Fix couple of minor issues in probe() To: Viresh Kumar CC: "Rafael J. Wysocki" , Dave Gerlach , Tero Kristo , , , Zumeng Chen References: <20180326215244.26304-1-s-anna@ti.com> <20180402063255.GC4714@vireshk-i7> From: Suman Anna Message-ID: <123a4223-600c-b477-df0f-5e0aab6ffcb3@ti.com> Date: Mon, 2 Apr 2018 10:45:07 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180402063255.GC4714@vireshk-i7> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Viresh, On 04/02/2018 01:32 AM, Viresh Kumar wrote: > On 26-03-18, 16:52, Suman Anna wrote: >> Commit 05829d9431df ("cpufreq: ti-cpufreq: kfree opp_data when >> failure") has fixed a memory leak in the failure path, however >> kmemleak still keeps reporting a leak even on successful probes. >> This is a false-positive and is mostly a result of the opp_data > > I don't agree to this reasoning for this particular patch. The code is just fine > and kmemleak is something that requires a fix. > >> variable not being stored anywhere in the probe function. The >> patch also returned a positive value on the get_cpu_device() >> failure instead of a negative value. > > Maybe that could have been fixed in a separate patch, cc'ing stable kernels as > well. > >> unreferenced object 0xecae4d80 (size 64): >> comm "swapper/0", pid 1, jiffies 4294937673 (age 154.420s) >> hex dump (first 32 bytes): >> 10 40 d9 ee 74 b7 db ee 00 24 ac ec 20 a3 ea c0 .@..t....$.. ... >> 00 26 ac ec 00 00 00 00 00 00 00 00 00 00 00 00 .&.............. >> backtrace: >> [] platform_drv_probe+0x50/0xac >> [] driver_probe_device+0x24c/0x330 >> [] bus_for_each_drv+0x54/0xb8 >> [<2c6f7021>] __device_attach+0xcc/0x13c >> [] bus_probe_device+0x88/0x90 >> [] device_add+0x38c/0x5b4 >> [<6f1af99b>] platform_device_add+0x100/0x220 >> [] platform_device_register_full+0xf0/0x104 >> [<4d492439>] ti_cpufreq_init+0x44/0x6c >> [<81222e89>] do_one_initcall+0x48/0x190 >> [<3bebf42a>] kernel_init_freeable+0x1f4/0x2b8 >> [<230ad7df>] kernel_init+0x8/0x110 >> [<43a165c3>] ret_from_fork+0x14/0x20 >> [< (null)>] (null) >> [<87288797>] 0xffffffff >> >> Fix both issues by replacing the previous logic by using the devres >> managed API for allocating the opp_data variable, and simplifying >> the get_cpu_device() failure return path. >> >> Fixes: 05829d9431df ("cpufreq: ti-cpufreq: kfree opp_data when failure") >> Cc: Zumeng Chen >> Signed-off-by: Suman Anna >> --- >> drivers/cpufreq/ti-cpufreq.c | 7 ++----- >> 1 file changed, 2 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c >> index a099b7bf74cd..7d353a21935b 100644 >> --- a/drivers/cpufreq/ti-cpufreq.c >> +++ b/drivers/cpufreq/ti-cpufreq.c >> @@ -217,7 +217,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev) >> if (!match) >> return -ENODEV; >> >> - opp_data = kzalloc(sizeof(*opp_data), GFP_KERNEL); >> + opp_data = devm_kzalloc(&pdev->dev, sizeof(*opp_data), GFP_KERNEL); >> if (!opp_data) >> return -ENOMEM; >> >> @@ -226,8 +226,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev) >> opp_data->cpu_dev = get_cpu_device(0); >> if (!opp_data->cpu_dev) { >> pr_err("%s: Failed to get device for CPU0\n", __func__); >> - ret = ENODEV; >> - goto free_opp_data; >> + return -ENODEV; >> } >> >> opp_data->opp_node = dev_pm_opp_of_get_opp_desc_node(opp_data->cpu_dev); >> @@ -285,8 +284,6 @@ static int ti_cpufreq_probe(struct platform_device *pdev) >> >> fail_put_node: >> of_node_put(opp_data->opp_node); >> -free_opp_data: >> - kfree(opp_data); >> >> return ret; >> } > > I am fine with the diff though, as that makes sense. So maybe do this ? > > - send separate patch for ENODEV thing > - and another patch to move to devres with a different reason than fixing false > positive OK, thanks for your comments. Will split this patch and post the new patches. regards Suman