Received: by 10.213.65.68 with SMTP id h4csp2060209imn; Sun, 1 Apr 2018 23:34:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx48beI6dDS5ypvtsWc5bNdo8S4eElnaEWo9SZtM8KWo1guS+Q46M9iVnh/ddoo8bCfmArfeP X-Received: by 10.101.83.199 with SMTP id z7mr1003193pgr.165.1522650861096; Sun, 01 Apr 2018 23:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522650861; cv=none; d=google.com; s=arc-20160816; b=d9N47nBHgB/uRSpbDT/cmHJjiPBkEULVcQ9ltsXKDoir02iuSo+9iulrBDVuy4w8nc DrPS0GgzFXV8EV36zjE2MkmrNJHjBRSp62O6RFhGmUTWiMOB8T3nZFrgl0qTYTPP5JsL NulDrozz8R6iYMt2bioFSsDEmSRrHo9H8DQtF8r/qS+NJoyAEiWFOn2ta6g8tqDDvxQA eeiX23XnlpwxSVTzSNyXWfNS9ek7AeoByth8nsWqVCQ9gkZCed31EAzi8wF3i6lUHdQm HeEsXaW9jsSi6pRhGd6uA7I6ld1vsSYcI/v0+CZBVW4mRjr1H6d0ih6vf048t+Mzsfkr d21A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=VDK2G2VbNVGJesZ95b3mlGqwZAvMooIhTrlT+SkfAYI=; b=uycd/L/uQASiMQJU9dvA6q9EpkHrf21wfsKjhUE/SoQnHN7DEfV2GQjkFr5sTZb/vl CJdB0V+frAQpXtAxEyIqNORtgGsyk7x6mZSYnzEKnZVLCiivYuiiVsjZDuWcQVls/QVV srSV3S/Ikt4pS+vhznEhpue0RjmstbNrNKqZFAXTzxlUMk2uXWuVzN1hXy2wpGc74P3t kYd4p5zsvIe/bhPcQqn3tlJdv3dR8JvX9+NfHX2SJFl1abxXCG/7KcqDGqo+HBavO6ir m3W6Wax0YoyIKRVEGeasckWtLg9n61MqcKMR90tHXG76X5EBcJ7h4Du/pyhPzoa16zlh h/Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b6YBuVph; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c3-v6si9889377pls.123.2018.04.01.23.34.07; Sun, 01 Apr 2018 23:34:21 -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=@linaro.org header.s=google header.b=b6YBuVph; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754114AbeDBGdB (ORCPT + 99 others); Mon, 2 Apr 2018 02:33:01 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:41374 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751971AbeDBGc7 (ORCPT ); Mon, 2 Apr 2018 02:32:59 -0400 Received: by mail-pf0-f193.google.com with SMTP id a2so6286635pff.8 for ; Sun, 01 Apr 2018 23:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VDK2G2VbNVGJesZ95b3mlGqwZAvMooIhTrlT+SkfAYI=; b=b6YBuVphb/KnPF9cMlguPD77FoEUkYlad1s7Mr5FHBaLMbX1OUKSGuzJZqdO+j2xI9 Y6S/TDBRjLpSj4sEVpz01ytOMPlXMcoHAzgq7fqP+VvUSF6CUmQhwC6UJjmc+fU4AQaY GSh+3MwxczK9G5oCPL31WoHkpUjmyNN87trHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VDK2G2VbNVGJesZ95b3mlGqwZAvMooIhTrlT+SkfAYI=; b=ti+04w0CAT+vs+Hw2qpEUrbeYf3V1xpKj01X88Q/ZoXrUULvQ9omBCVmQQWP6JGVxC daMjbnMTIJqF5MDeOYpUjA2FjQzPqbKsGBLPd+asZoaSDs++TaHCfb9A1/iUwoGg/ypG 8VsPJSWWc+TBBZ/HaryJplwrlSOpwgLnt9eX/uqPJcfHiWxHcc7iCy9FJQmkxeRhFM4d zIh/KS0oMSss0q/1PioIUJFJv1KWNRMEdtNlF3IGpgXc9GL+O/LCvzU0KuOZ8bF8VBCF XSEHE/53JIbi5uICrQQqP3ukcLf5L37fsT9gw0+WytxhB2w27YPjelXDGx0XFQjUd2wF U1MA== X-Gm-Message-State: AElRT7GuMtsmyEU/sDu/39hCIsH3r0VNU+U5XNOp/ILRVFqlwxUw27Ak J/SO4Ik/uizel9G5CYdAVW1wEw== X-Received: by 10.99.125.19 with SMTP id y19mr5524313pgc.125.1522650779141; Sun, 01 Apr 2018 23:32:59 -0700 (PDT) Received: from localhost ([122.171.228.188]) by smtp.gmail.com with ESMTPSA id g26sm29808408pfk.173.2018.04.01.23.32.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Apr 2018 23:32:57 -0700 (PDT) Date: Mon, 2 Apr 2018 12:02:55 +0530 From: Viresh Kumar To: Suman Anna Cc: "Rafael J. Wysocki" , Dave Gerlach , Tero Kristo , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zumeng Chen Subject: Re: [PATCH] cpufreq: ti-cpufreq: Fix couple of minor issues in probe() Message-ID: <20180402063255.GC4714@vireshk-i7> References: <20180326215244.26304-1-s-anna@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180326215244.26304-1-s-anna@ti.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- viresh