From patchwork Mon Mar 26 21:52:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 132435 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp4335792ljb; Mon, 26 Mar 2018 14:52:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELtYLXNTevOmMKQCInX9JOc+rduPOVISYr5BfNxMRwTwJGwdRyLmeMAS78S2CgiglDJsW62a X-Received: by 10.99.114.77 with SMTP id c13mr29599037pgn.8.1522101177529; Mon, 26 Mar 2018 14:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522101177; cv=none; d=google.com; s=arc-20160816; b=Gv4T75whIZepjIjpcD3LS9MRF4n7S6KwyrUvAaTwi904RyU7y+S0A64MCr8VBAsHSg b89oxQ6lb/mdu7N3KhlLK8ieKUImWV5hoXwOcSorJzd/nK/XsoW154/0T0mnWQ68k3qA guZwZodXrqiKJDZpN25SMEHFNIxpEKRSs5yJUo6i4yCLNKH3hpRhN6gtkAIpjjD7sBEe bMvnxdm+yoPFTKwQCMUvHcxeT6OWk63B1RF1ujFOAc64OrbZ7Aa+bInAP8/9meMukUhu rZLrjzruVD70RZ+imkLnYibo2TgUWdLA7oYBhQy/ZG9qvyXulX1oPRU4QTjZpV44E+M5 kZJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=2Dgz+rsWkzbEXQ6SOlOwzrgp/sP1Wsz+aaxf3XOWTUU=; b=v6ZyB8+cCATqrznojRE6yJkv4S4TqxoZkvcsADaSDgXjqIYuussqDvrkge8P6KIANw eolcF9/8qmpWUo3Dv+HMZfbdl04tP6Vf9FLlBAyjpXUQo6JZr+/jNG4ldnB3RKz9iLte K3CalSjq6ZukW1Tq/FRGCF8TG41YtbHyJgi3Z6EO4Iv6tr2cs3PmLJdZqJCJ4bfDRVGQ NU6n2dv8q2QYBIkyxUe2F6b9E07AJxVAII4BaqkKqvyzKkxyA0zK0PG5wJRgZdImm6H+ l/RD8p9S07RIJkil62t2/+BguX1jBhTWnqcNjTybN8lRnZiuQLmrrR1/ADIx2tb4igwc qLTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=C5bZ8dIH; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) 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 d186si10705581pgc.81.2018.03.26.14.52.57; Mon, 26 Mar 2018 14:52:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=C5bZ8dIH; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751107AbeCZVwz (ORCPT + 5 others); Mon, 26 Mar 2018 17:52:55 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:40491 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132AbeCZVwz (ORCPT ); Mon, 26 Mar 2018 17:52:55 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w2QLqp8t019226; Mon, 26 Mar 2018 16:52:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1522101171; bh=2/rx0f0M4qcd/aXmWL+8HbIm0EIXI1WH5b28xdJ28U8=; h=From:To:CC:Subject:Date; b=C5bZ8dIHxMoBzK9JGmh61vciw64au7AOfAlNWTCvSMaE7GPyy8cKBvvSUvJHJVjff ESPrppvklTvaEIC4LREMtJXKcN6NgjjGqol+hhXrljXEPvD/Xcozg3Evk/f+MVqWx2 AdH0YlaOowAMxYLJHAIj/TecX5ViDO78Xoi2mLfs= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2QLqpWb024833; Mon, 26 Mar 2018 16:52:51 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Mon, 26 Mar 2018 16:52:50 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Mon, 26 Mar 2018 16:52:50 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2QLqosE030803; Mon, 26 Mar 2018 16:52:50 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.58.153]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w2QLqox17385; Mon, 26 Mar 2018 16:52:50 -0500 (CDT) From: Suman Anna To: Viresh Kumar CC: "Rafael J. Wysocki" , Dave Gerlach , Tero Kristo , , , Suman Anna , Zumeng Chen Subject: [PATCH] cpufreq: ti-cpufreq: Fix couple of minor issues in probe() Date: Mon, 26 Mar 2018 16:52:44 -0500 Message-ID: <20180326215244.26304-1-s-anna@ti.com> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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 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. 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(-) -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }