Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751581AbdH1AXG (ORCPT ); Sun, 27 Aug 2017 20:23:06 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:21421 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751457AbdH1AXD (ORCPT ); Sun, 27 Aug 2017 20:23:03 -0400 X-AuditID: b6c32a48-f79a16d00000362a-8c-59a362654228 MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset="utf-8" Message-id: <59A36264.4030605@samsung.com> Date: Mon, 28 Aug 2017 09:23:00 +0900 From: Chanwoo Choi Organization: Samsung Electronics User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 To: myungjoo.ham@samsung.com, Kyungmin Park Cc: "rafael.j.wysocki@intel.com" , "chanwoo@kernel.org" , Inki Dae , "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" , "stable@vger.kernel.org" Subject: Re: [PATCH 01/12] PM / devfreq: Fix memory leak when fail to register device In-reply-to: <20170828001753epcms1p658026b4f636aa4c0aee6f22bc128ebe3@epcms1p6> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkk+LIzCtJLcpLzFFi42LZdljTQjc1aXGkQc9udouJN66wWEy6P4HF 4mzTG3aLy7vmsFl87j3CaHG7cQWbxeMVb9ktFmx8xOjA4bF4z0smj02rOtk8+rasYvT4vEku gCUq1SYjNTEltUghNS85PyUzL91WyTs43jne1MzAUNfQ0sJcSSEvMTfVVsnFJ0DXLTMH6Awl hbLEnFKgUEBicbGSvp1NUX5pSapCRn5xia1StKGhkZ6hgbmekZGRnolxrJWRKVBJQmpG28m3 bAU/+Cv2LNrK0sD4nqeLkZNDQsBE4s2THhYIW0ziwr31bF2MXBxCAjsYJXYv2csI4XxnlOi5 38QI03Hiy1ImiMQGRoltfd+YQRK8AoISPybfAxrFwcEsIC9x5FI2SJhZQFPix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LH0xxxmkASngJ/ExLM32CcwCsxCcukshEtnIVy6gJF5FaNkakFx bnpusVGBUV5quV5xYm5xaV66XnJ+7iZGYJhvO6zVv4Px8ZL4Q4wCHIxKPLwddosjhVgTy4or cw8xSnAwK4nwiicChXhTEiurUovy44tKc1KLDzFKc7AoifNm9s2IFBJITyxJzU5NLUgtgsky cXBKNTAWmly3OChyyTP985ELMsuPyrkXpNxv9vodqh9foHKK57fvvc77omLlm3pviV7mXXJh /0WnF9sSxUpuXxHKfdY4nceYk2nT1m+rplUtbV0ZM/llgZGL663XXiamkxeplYt16C5UFP5v oPZ2AVN7heVWJt77Dht/Ss2z+3L081HL2nn1D5xf2/IosRRnJBpqMRcVJwIAtcPBtW8CAAA= X-CMS-MailID: 20170828002300epcas2p2c1e0d8c40e27f7f2a9d84c844605e738 X-Msg-Generator: CA X-Sender-IP: 182.195.42.143 X-Local-Sender: =?UTF-8?B?7LWc7LCs7JqwG1RpemVuIFBsYXRmb3JtIExhYihTL1fshLw=?= =?UTF-8?B?7YSwKRvsgrzshLHsoITsnpAbU2VuaW9yIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?Q2hhbndvbyBDaG9pG1RpemVuIFBsYXRmb3JtIExhYi4bU2Ft?= =?UTF-8?B?c3VuZyBFbGVjdHJvbmljcxtTZW5pb3IgRW5naW5lZXI=?= X-Sender-Code: =?UTF-8?B?QzEwG1RFTEUbQzEwVjgxMTE=?= CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20170824014259epcas2p398a53a9a76d9aff7e35cf8515ec4e46a X-RootMTR: 20170824014259epcas2p398a53a9a76d9aff7e35cf8515ec4e46a References: <1503538979-22693-2-git-send-email-cw00.choi@samsung.com> <1503538979-22693-1-git-send-email-cw00.choi@samsung.com> <20170828001753epcms1p658026b4f636aa4c0aee6f22bc128ebe3@epcms1p6> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1971 Lines: 69 On 2017년 08월 28일 09:17, MyungJoo Ham wrote: >> When the devfreq_add_device fails to register deivce, the memory >> leak of devfreq instance happen. So, this patch fix the memory >> leak issue. Before freeing the devfreq instance checks whether >> devfreq instance is NULL or not because the device_unregister() >> frees the devfreq instance when jumping to the 'err_init'. >> It is to prevent the duplicate the kfee(devfreq). >> >> Cc: stable@vger.kernel.org >> Fixes: ac4b281176a5 ("PM / devfreq: fix duplicated kfree on devfreq pointer") >> Signed-off-by: Chanwoo Choi >> --- >> drivers/devfreq/devfreq.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) > > This looks like to be duplicated. Please check your repo basis. These patches is based on the v4.13-rc6. After merged ("PM / devfreq: fix duplicated kfree on devfreq pointer"), this patch doesn't consider the free of memory when error case. After applying this patch, this patch consider the error case when jumping the err_dev statement with goto. device_unregister(&devfreq->dev); err_dev: if (devfreq) kfree(devfreq); > > > Cheers, > MyungJoo > >> >> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c >> index dea04871b50d..a1c4ee818614 100644 >> --- a/drivers/devfreq/devfreq.c >> +++ b/drivers/devfreq/devfreq.c >> @@ -564,7 +564,7 @@ struct devfreq *devfreq_add_device(struct device *dev, >> err = device_register(&devfreq->dev); >> if (err) { >> mutex_unlock(&devfreq->lock); >> - goto err_out; >> + goto err_dev; >> } >> >> devfreq->trans_table = devm_kzalloc(&devfreq->dev, >> @@ -610,6 +610,9 @@ struct devfreq *devfreq_add_device(struct device *dev, >> mutex_unlock(&devfreq_list_lock); >> >> device_unregister(&devfreq->dev); >> +err_dev: >> + if (devfreq) >> + kfree(devfreq); >> err_out: >> return ERR_PTR(err); >> } >> -- >> 1.9.1 > > -- Best Regards, Chanwoo Choi Samsung Electronics