Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757416AbbEETmn (ORCPT ); Tue, 5 May 2015 15:42:43 -0400 Received: from mail-bn1on0142.outbound.protection.outlook.com ([157.56.110.142]:44306 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753014AbbEETml (ORCPT ); Tue, 5 May 2015 15:42:41 -0400 Authentication-Results: freescale.com; dkim=none (message not signed) header.d=none; Message-ID: <1430854949.16357.240.camel@freescale.com> Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support From: Scott Wood To: Rivera Jose-B46482 CC: Dan Carpenter , "devel@driverdev.osuosl.org" , "agraf@suse.de" , "arnd@arndb.de" , Sharma Bhupesh-B45370 , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , Yoder Stuart-B08248 , Erez Nir-RM30794 , "katz Itai-RM05202" , Hamciuc Bogdan-BHAMCIU1 , Marginean Alexandru-R89243 , Schmitt Richard-B43082 Date: Tue, 5 May 2015 14:42:29 -0500 In-Reply-To: References: <1430242750-17745-1-git-send-email-German.Rivera@freescale.com> <1430242750-17745-2-git-send-email-German.Rivera@freescale.com> <20150430114957.GW14154@mwanda> <20150505084830.GL16501@mwanda> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [2601:2:5800:3f7:12bf:48ff:fe84:c9a0] X-ClientProxiedBy: BN3PR09CA0001.namprd09.prod.outlook.com (25.160.111.139) To BY1PR03MB1482.namprd03.prod.outlook.com (25.162.210.140) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1482; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY1PR03MB1482;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1482; X-Forefront-PRVS: 0567A15835 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(377424004)(51704005)(24454002)(87976001)(23676002)(50226001)(5890100001)(5820100001)(36756003)(122386002)(103116003)(33646002)(86362001)(62966003)(42186005)(2950100001)(77156002)(46102003)(50986999)(19580405001)(93886004)(40100003)(50466002)(47776003)(5001960100002)(92566002)(107886002)(110136002)(76176999)(3826002)(4001430100001)(4001450100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR03MB1482;H:[IPv6:2601:2:5800:3f7:12bf:48ff:fe84:c9a0];FPR:;SPF:None;MLV:sfv;LANG:en; X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2015 19:42:35.5962 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1482 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1635 Lines: 39 On Tue, 2015-05-05 at 11:08 -0500, Rivera Jose-B46482 wrote: > > > > to read what "goto error;" does. The error handling here calls > > > > devm_kfree() which is not needed... devm_ functions automatically > > > > clean up after themselves. This seems a pattern throughout. Do a > > > > search for > > > > devm_free() and see which ones are really needed or not. > > > > > > > I know that memory allocated with devm_kzalloc() is freed at the end > > > of the lifetime of the device it is attached to. However, in error > > > paths, why wait until the device is destroyed? Why not free the memory > > > earlier so that it can be used for other purposes? > > > Why then do the devm_kfree() function exist? > > I will not remove the devm_free() calls unless the upstream maintainer > requires me to do so. The whole point of devm is to simplify (often poorly tested) error paths. You're trying to optimize the error path instead of simplify it, which doesn't make sense. devm_kfree() is for the uncommon case when you want to free the memory in a situation where the device isn't being unbound any time soon, but you still want the memory to be handled by devm for some reason. Most users of devm_kzalloc() do not use devm_kfree(): scott@snotra:~/fsl/git/linux/upstream$ git grep devm_kzalloc|wc -l 2750 scott@snotra:~/fsl/git/linux/upstream$ git grep devm_kfree|wc -l 118 -Scott -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/