Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751851AbdH1AR6 (ORCPT ); Sun, 27 Aug 2017 20:17:58 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:20315 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751566AbdH1AR4 (ORCPT ); Sun, 27 Aug 2017 20:17:56 -0400 X-AuditID: b6c32a37-f79886d000004f16-5f-59a36131a956 Mime-Version: 1.0 Subject: RE: [PATCH 01/12] PM / devfreq: Fix memory leak when fail to register device Reply-To: myungjoo.ham@samsung.com From: MyungJoo Ham To: Chanwoo Choi , 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" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <1503538979-22693-2-git-send-email-cw00.choi@samsung.com> X-Drm-Type: N,general X-EPLocale: ko_KR.EUC-KR X-EPWebmail-Msg-Type: personal X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Illegal-Object: Syntax error in X-Sender: address found on vger.kernel.org: X-Sender: =?utf-8?B?U2Ftc3VuZyBFbGVjdHJvbmljcxtBcnRpZmljaWFsIEludA==?= ^-Extraneous program text X-Sender-IP: 10.113.73.204 X-Local-Sender: =?UTF-8?B?7ZWo66qF7KO8G0FydGlmaWNpYWwgSW50ZWxsaWdlbmNlIDNMYWIoUy9X?= =?UTF-8?B?7IS87YSwKRvsgrzshLHsoITsnpAbUHJpbmNpcGFsIEVuZ2lu?= =?UTF-8?B?ZWVy?= X-Global-Sender: =?UTF-8?B?TXl1bmdKb28gSGFtG0FydGlmaWNpYWwgSW50ZWxsaWdlbmNlIDNMYWIu?= =?UTF-8?B?G1NhbXN1bmcgRWxlY3Ryb25pY3MbUHJpbmNpcGFsIEVuZ2lu?= =?UTF-8?B?ZWVy?= X-Sender-Code: =?UTF-8?B?QzEwGxtDMTBWODI5MQ==?= Message-ID: <20170828001753epcms1p658026b4f636aa4c0aee6f22bc128ebe3@epcms1p6> Date: Mon, 28 Aug 2017 00:17:53 +0000 X-CMS-MailID: 20170828001753epcms1p658026b4f636aa4c0aee6f22bc128ebe3 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-MTR: 20170828001753epcms1p658026b4f636aa4c0aee6f22bc128ebe3 CMS-TYPE: 101P X-Brightmail-Tracker: H4sIAAAAAAAAA01Se0hTcRTmt3vd7qzFdT46GJhcskzc3J0zr6UZ9BKykiTMLNZVL9Paq92t hxRIZD4ws8iYZmVNKk3QJB/TqJgZZSlF74cmSUmkPTAxoaJd76L++37f7zvfd87hEJiyQhpK 5JvtnM3MGimpP97es1il0rKuTE31aub4iyc48/z7qB9z4m0lzvQfGpMxj7tqpczE0duIGbk8 LmPqrr5DK4gU1/WPkpTWxlJpSsW1RpQy0RqWhm/lEvM4NpezhXPmHEtuvtmQRK1L16/Uxy3R 0Co6gYmnws2siUuiVqWmqdbkG71dUOF7WKPDS6WxPE/FLE+0WRx2LjzPwtuTqCya1qppTbxa q9WqdbHbl2rjvJIdXF7lQBNm7Z+1b2LKiRWiTnkZkhNA6qB2atpPxCHwcKhZWob8CSXZieBr S42sDBGEggyAX52BgiaQzICzPwZxAStJCgpf3sBEPgZKhtuRgKWkCtpaRE0QuRm66yowwRMj uyTQ4BzHxTAFOIvf+/A86LjUhoQsObkGpkc0Ih0ML6+My0QM8ObTQ4mIw+DUZBP2V/Plzjkk 4iAoGur38QEwPN2NhFwgixC8ufbBZxQKr1zPJOLHRQSux+9l4uMSguL6q1KhC/CO4+5YKRQo yPXQfmJIKmCcjID7v0d9CaugpKFypiOMnA8d47WYUIqRi6G5K0aUJEGp87BPMgc+T5b7Fr0Q PN31skq0oObfemv+M6r5Z1SHsEYUwll5k4HjaWusmmdNvMNsUOdYTK1o5haj4jtRy0CqB5EE omYrYJErU+nH7uH3mzwICIwKUvRmeClFLru/gLNZ9DaHkeM9KM47z3EsNDjH4r1ss11P6xI0 uiVa78kl0DQ1VxHS/GyLkjSwdm4Xx1k52986CSEPLUT4vciDRyK2n5UnX/dkZ/Yoj+3d5i7o q0q/5XRD3+a1sxsiA1/1Zq/d4DY+irf+OHoXjx57bRop2b3z5MKf1Wn0U1VbyabBX7oDpy+4 pzVZQ8n6Jz2fH114vnxqeAeKrl+2c/Usw7fXk7H7toY8GD6fXlV+s92xTLOx/8ymmKwrb8sH Uymcz2PpKMzGs38AVkuQr6EDAAA= 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> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1439 Lines: 46 > 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. 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