From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934959Ab3BTIKT (ORCPT ); Wed, 20 Feb 2013 03:10:19 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:45799 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934838Ab3BTIKR (ORCPT ); Wed, 20 Feb 2013 03:10:17 -0500 Date: Wed, 20 Feb 2013 00:10:14 -0800 From: Dmitry Torokhov To: Jingoo Han Cc: "'Samuel Ortiz'" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/11] mfd: menelaus: use devm_request_irq() and devm_kzalloc() Message-ID: <20130220081014.GA4268@core.coreip.homeip.net> References: <002601ce0f30$d6b81c40$842854c0$%han@samsung.com> <002c01ce0f31$48d55e00$da801a00$%han@samsung.com> <20130220073044.GB2648@core.coreip.homeip.net> <000801ce0f41$00e79170$02b6b450$%han@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000801ce0f41$00e79170$02b6b450$%han@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 20, 2013 at 05:05:10PM +0900, Jingoo Han wrote: > On Wednesday, February 20, 2013 4:31 PM, Dmitry Torokhov wrote: > > > > Hi Jongoo, > > > > On Wed, Feb 20, 2013 at 03:12:38PM +0900, Jingoo Han wrote: > > > Use devm_request_irq() and devm_kzalloc() to make cleanup paths > > > more simple. > > > > > > > ... > > > > > @@ -1269,9 +1266,7 @@ static int __exit menelaus_remove(struct i2c_client *client) > > > { > > > struct menelaus_chip *menelaus = i2c_get_clientdata(client); > > > > > > - free_irq(client->irq, menelaus); > > > flush_work(&menelaus->work); > > > - kfree(menelaus); > > > the_menelaus = NULL; > > > return 0; > > > > This conversion is certainly wrong - you really want to disable IRQ and > > then wait for the scheduled work to finish before freeing memory. Here > > you flush work but nothing stops IRQ from firing and scheduling that > > work again. > > Yes, you're right. > I will use devm_free_irq() before flush_work(). Why change it at all if you have to call it manually in both error unwinding and menelaus_remove() cases? BTW, that __exit markup on menelaus_remove() is surprising... I am pretty sure it can be unbound via sysfs and so there will be a nasty oops. -- Dmitry