From patchwork Tue Jan 12 10:37:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 8016151 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D8E0A9F2F4 for ; Tue, 12 Jan 2016 10:51:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D94C20384 for ; Tue, 12 Jan 2016 10:51:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F53D20383 for ; Tue, 12 Jan 2016 10:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933448AbcALKvn (ORCPT ); Tue, 12 Jan 2016 05:51:43 -0500 Received: from mail-am1on0086.outbound.protection.outlook.com ([157.56.112.86]:17713 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933125AbcALKvl (ORCPT ); Tue, 12 Jan 2016 05:51:41 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ping.bai@nxp.com; Received: from b51503-01.ap.freescale.net (123.151.195.53) by AM3PR04MB529.eurprd04.prod.outlook.com (2a01:111:e400:8823::28) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 12 Jan 2016 10:37:09 +0000 From: Bai Ping To: , CC: Subject: [PATCH] thermal: common: free the mem allocated when out of use Date: Tue, 12 Jan 2016 18:37:23 +0800 Message-ID: <1452595043-7239-1-git-send-email-ping.bai@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [123.151.195.53] X-ClientProxiedBy: PS1PR06CA0028.apcprd06.prod.outlook.com (2a01:111:e400:7829::38) To AM3PR04MB529.eurprd04.prod.outlook.com (2a01:111:e400:8823::28) X-Microsoft-Exchange-Diagnostics: 1; AM3PR04MB529; 2:6yI5FSaKt0NwI/O01uabNYldBhObUVhMmew7p5kqDrEqnY62WNgkFj/upb/7jtVKrrWCCP0I27MLSSqHHqe//LRnRezs9qsIJh3nbxy7S3z7eQMKng+ojNN5TAMb7OzjtDESkH+E2KW9AmB3aB2tgg==; 3:+N4t3S4NgOCd300v2Dime+NbsdbSY7JCp8SlOEKcL3h0heBGNfNWwLTJeOKYqYlKAlXj7ckwUaEMAfeDV/Gk9iP3egc5C23V8dcUoHy6AGZ65kwqLhmoVOL5K/00+Pvl; 25:LkduJTTqT6ZOCBhcwTzGGAR4+iZP4z20hXXIK8/DyKOrOIw+Vs0P7LMzja44EYECm66UifHFhP6/sP0j0utwWi3MhjAELbqpMXU2A2QW6tiUJEkLJG1m+RaGOQUkVbyn7iRizDmtLZiuLU5VRGKxqkbxOv55gAlh/JySsrIvi20fvROgSDGKvGwMMGeqiAHq2lEGo8OPQEMHJIHAweUdBkKo+hyh4N2gFhea+JfyYiBEf2H7xUs8/lR11e8Ru4Xa X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM3PR04MB529; X-MS-Office365-Filtering-Correlation-Id: 4b880bf8-6e9c-4298-c8cf-08d31b3c5467 X-Microsoft-Exchange-Diagnostics: 1; AM3PR04MB529; 20:uV6dXbWwK2aiqKx8EHUTq4zU7OZ6Z9V5NOxRthazG7jeFUIRglaSkq3hD9WzUFlP18fprTo3pfPWIdY6hSk4I8V+o1OroGn1muOiBrY0h5T+0+pw5pNO9RUvriEF3zoqHrbXugaT2KvR14lrMWu6QT4Hht0ndkk0u35PMCkwIjIE1U1zchO5qX4auuMxmtxQQCI6ahSldn3ueJ+1Fw2SRct3PLffm6L92MU4x03LeMlcrJSwGAZU7J3eMHU90lumyFi0v6r/DHsQi35qA4wmv/n0NWbiFVk2cWSiQ9MxNML45ecpFDZq0DKZn52B+1W2rhjid6muek2w1cB9NyvpPJa/YFp2S6z+1wFB6C+AGrJ//e+eMGbkzLzwLDMasGFqvjKIosGU+99h4sgm37KQlc6AViMZgH7YPZdtthAC4aSPjdRXfBDqjbUj0TceJMl0CzAspvx176ZDqEFSfWODir66DqVip4FhQQnXxeF7TWwfVwsheq++6UVjSfZqcUVs; 4:rHbPLwZkMdCBqUzC5Yxc1fJ1TNKsUVCQ0DLqRbXErn+/9S35ZhRknvEsqV6RgFbZE0M7cUffGbryxUO4VUOLF9/nS8fBWEQl+Yh9kSbNa39lH5+Nb6BEilwIVKgQ3/s98qHivhX/LQsyQDABOE049twFlnFu9fJRatdCCuuJz3/yK20TAg3Lm1BRawA5CECrW90zt0jvAlG6aC5oAi47U0EsVcq8ZchcdjAyT6npPo2BwYWizDVBJ4gZgDMOD5WoPSGcxTiDEs04VQKmbyeJQbG/d5k99ExG3zSB3IQaAVFr5i+y/ARXKrWUoZ+VuEZpAAi3gMMhrdluLdPLbK52j14lkejakVCxXdSI4AEvCXtTKlsVK8X24OTYAAFpKCyQnfX7nbraqYqmslya0pgF/pdG4wmFt2QY52UJuJz xGMI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046); SRVR:AM3PR04MB529; BCL:0; PCL:0; RULEID:; SRVR:AM3PR04MB529; X-Forefront-PRVS: 081904387B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(2906002)(50226001)(586003)(48376002)(1096002)(47776003)(19580395003)(189998001)(97736004)(122386002)(5001770100001)(19580405001)(81156007)(42186005)(5001960100002)(40100003)(6116002)(66066001)(87976001)(5003940100001)(33646002)(50466002)(5008740100001)(86362001)(3846002)(5004730100002)(4326007)(105586002)(229853001)(101416001)(106356001)(50986999)(36756003)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR04MB529; H:b51503-01.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM3PR04MB529; 23:GuKlPa/A2ZrZHMjr0Ghcj4fLDLJwaS+yR3yiYik5qM?= =?us-ascii?Q?vcKnbrPO2QI8IaoIe1nsIdwDmGYkR784xJF5y29Iq81C7AEBP6oFv2KhfxSn?= =?us-ascii?Q?i1faT5YoK1gTTrbjwLSNkeN1vneq7kJqkKR+FAd44F4dtkR8CjuGHPlISIMw?= =?us-ascii?Q?w2hzdSdd8CcgiWKhFTYi0VBAm5L5Docbr1oCBMfZ568J6rdYEos3cUV3Bhki?= =?us-ascii?Q?lCVVzD2GDlxE5Ysqeq2iYkHoU8MmfQpy/wZIJpNHZ2NXuYarznSiETUpIAjM?= =?us-ascii?Q?530JMZxePvLA+arMCpS2LjVymS5wdrW9NOZ47YmYJtFf50uTL4R3eXZcaPYk?= =?us-ascii?Q?Dt1cRacoAxwWvbsd7UrC+sQZZlfeAeD+HHGB3QVEH01aKAAZu+XzNsdsZDtK?= =?us-ascii?Q?7O0ZPKuQOl7pPxN5yzj/tUHQXGYqcIgrNk+XStut//BUB2ZlfWbkIWN3HryN?= =?us-ascii?Q?EXqH9Pm92TuRj6oUzw3U4V2BA5nxZ0D/K+iiFyCKIIoE5c7C04slIykheXOL?= =?us-ascii?Q?vm6WZtK8iErrzF4C8LLHlL9sfXZtGQJ/a17Whbwv0rCH1ZYFl5mJJSOJ7m9t?= =?us-ascii?Q?3vSpmwIl/EnNttKTyeMNzVaQBuNKRwTXgkqUtfo0S44lpfipB8rC/AWXZcZ6?= =?us-ascii?Q?4VVA0i8Eo7ywZAliJIT6nX/g2ZQrBNf0mh7YbtoBptHtkTOIgJo7p9N2MqLH?= =?us-ascii?Q?mjF0XF0UDnH45BNG+WEWbpEv4XEABPzGrQ5JS5g7/Oe40Pz0dO2OnuyKXjQJ?= =?us-ascii?Q?rdNEWjalGlNnm0spSpvmI6TrsOXC0uK27oOCjylqlM9LTuQFwGMk38WVHE0v?= =?us-ascii?Q?8wlR3vqizdtp98NJzh7en1QRetQ5XJ5H5JAtY3SwUo251Y4HTtQMa0cPPBIL?= =?us-ascii?Q?uuVMwJYVnbvt2PkJYA6BQKf1n9WQd6NPkR3TbTHnOqYix2vw2suxB4n4xwIP?= =?us-ascii?Q?IEht41FT8GSKPlpdfEJfM4COr08Ng/k+LocAKaZ4eO2dCihnhhQbtXO58nqh?= =?us-ascii?Q?J1Ned5kzMJGu302XuEzNfu?= X-Microsoft-Exchange-Diagnostics: 1; AM3PR04MB529; 5:/vMcr3EEWioHAWZWJq5SEKXjKWVnwCPytEdaJM52cEj+6BL93GD2faMNnWuZxz+NOIZ3lSBnJGnxmbwV9J3b3o7BXBJZn2nEO4m1h1VbPEJCS844+YeJehRfk7mzHasqhzkpikTicxGuUL0PglGUzw==; 24:bO9Qzg24sQyatP1TCexUZmL1ii/HgiDQ6cgCnQpJhySQ8FyXZ0XuM8m8lATUJFYmZ6YSYsY+RvPLXJq30k70v1R8GMUu02ZDOyLrv0XE8zE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2016 10:37:09.5728 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR04MB529 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The memory resource allocated for thermal_zone_device should be freed when thermal_zone_device registers failed or the thermal_zone_device unregistered. Signed-off-by: Bai Ping --- drivers/thermal/thermal_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 7f7a3ca..1a9cf31 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -2012,6 +2012,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, unregister: release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); device_unregister(&tz->device); + kfree(tz); return ERR_PTR(result); } EXPORT_SYMBOL_GPL(thermal_zone_device_register); @@ -2081,6 +2082,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) idr_destroy(&tz->idr); mutex_destroy(&tz->lock); device_unregister(&tz->device); + kfree(tz); return; } EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);