From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756149AbbGTIST (ORCPT ); Mon, 20 Jul 2015 04:18:19 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:15453 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756085AbbGTISQ (ORCPT ); Mon, 20 Jul 2015 04:18:16 -0400 Subject: Re: question about drivers/dma/dma-jz4780.c To: Julia Lawall References: CC: , , From: Alex Smith Message-ID: <55ACAEC5.7090000@imgtec.com> Date: Mon, 20 Jul 2015 09:18:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.154.136] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/07/2015 10:08, Julia Lawall wrote: > The file drivers/dma/dma-jz4780.c has a probe function that sets up irqs > using devm_request_irq. The probe function then ends with: > > err_unregister_dev: > dma_async_device_unregister(dd); > > err_disable_clk: > clk_disable_unprepare(jzdma->clk); > return ret; > } > > The remove function, on the other hand contains: > > of_dma_controller_free(pdev->dev.of_node); > devm_free_irq(&pdev->dev, jzdma->irq, jzdma); > dma_async_device_unregister(&jzdma->dma_device); > > The need for calling devm_free_irq explicitly would be that it needs to > occur before dma_async_device_unregister, to eg avoid a reference to a > dangling pointer. But devm_free_irq is implicitly called after the call > to dma_async_device_unregister at the end of the probe function. Which > one is correct? > > julia Hi, I think the explicit devm_free_irq() here is unnecessary, as when remove is called there should be no remaining users of the DMA controller and therefore no chance of an IRQ occurring between the controller being unregistered and an implicit IRQ release afterwards. I recently sent a series of fixes for this driver, I will send a new version with a patch to remove the unnecessary free. Thanks, Alex