From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75998194C92; Mon, 30 Sep 2024 19:14:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727723695; cv=none; b=nmm8w0i7UeNIo/OOo5sMVgsftoIVOyh9qs/Ec4E39fde7iTcaMMy/hCN6ys/el2adFuyNDK5hohgGZyydvjDm3Yx9ecYQQrOmUMBbvTnsvnK0a9Bv3P0iWvw3o9ZErM/zuCRBYG54iBEIOWIc6MsaEQ9PZfHlIyV/wQhkvHJF1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727723695; c=relaxed/simple; bh=yPPWd8LSLMPsco9pid8gUD9uR0sV8t8Iz+vJoaDxXpQ=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=AQ2oWkCC5DUBZlDyUq2tEmlti8zZ09eWgcr7dvPiGBSo5qZg4JUmVjLTD+gJ602/wkk8e57xExphFgBgbvRTcNEfH/d6BbzwiS1lPKtNycgixfYbMaBwTZw/XLP0HYrhCiwIUGEE8CnLPKJDWwQ/unmBveZd9letIQPDcYdKS/4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jqWvpOiL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jqWvpOiL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03108C4CEC7; Mon, 30 Sep 2024 19:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727723695; bh=yPPWd8LSLMPsco9pid8gUD9uR0sV8t8Iz+vJoaDxXpQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jqWvpOiLHHYA8d2epXFWjWXbZbJZV40SDaFwKv+tRZjpZNJlkX7BdQNdlbQGxUtK+ 1+Cye02uzLaVUM38omXZqQQo6QzqdTKoKwTFI0+YhnVoO0c7NKMDPoYAwGoEIY5frg RY7KrbmuZMjYg3JJqcVPOY3rM2zPdqM61xvPNEPuIvEMmiXjIxpm4Yp9xdB2UdlAOj DJlJNCFrRxhNH8cqFJWZaAKRRZM0R7K3SY3JSP0NHa07yBs0nt93s+owvnCe4WmYqH TMN2TBk0M7AVu3fM72tojiGZKf+Z5vEu61d1Esic8jn8pBY0MJCq+k/LMUJqL8otGi dOEiQy6STUyYQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1svLrA-00GXWp-SB; Mon, 30 Sep 2024 20:14:52 +0100 Date: Mon, 30 Sep 2024 20:14:52 +0100 Message-ID: <86frph6jir.wl-maz@kernel.org> From: Marc Zyngier To: Fabrizio Castro Cc: Thomas Gleixner , Geert Uytterhoeven , Prabhakar Mahadev Lad , "linux-kernel@vger.kernel.org" , Chris Paterson , Biju Das , "linux-renesas-soc@vger.kernel.org" Subject: Re: [PATCH] irqchip/renesas-rzg2l: Fix missing put_device In-Reply-To: References: <20240930145539.357573-1-fabrizio.castro.jz@renesas.com> <87ldz9uomz.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: fabrizio.castro.jz@renesas.com, tglx@linutronix.de, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com, linux-kernel@vger.kernel.org, Chris.Paterson2@renesas.com, biju.das.jz@bp.renesas.com, linux-renesas-soc@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 30 Sep 2024 17:36:20 +0100, Fabrizio Castro wrote: > > Hi Marc, > > Thanks for your feedback. > > > From: Marc Zyngier > > Sent: Monday, September 30, 2024 4:50 PM > > To: Fabrizio Castro > > Subject: Re: [PATCH] irqchip/renesas-rzg2l: Fix missing put_device > > > > On Mon, 30 Sep 2024 15:55:39 +0100, > > Fabrizio Castro wrote: > > > > > > rzg2l_irqc_common_init calls of_find_device_by_node, but the > > > corresponding put_device call is missing. > > > > > > Make sure we call put_device both when failing and when succeeding. > > > > What sort of lifetime are you trying to enforce? > > Function rzg2l_irqc_common_init uses pdev->dev until its very end. > My understanding is that we should decrement the reference counter > once we are fully done with it. Is my understanding correct? "done with it" is what scares me. Specially when I see code like this: rzg2l_irqc_data = devm_kzalloc(&pdev->dev, sizeof(*rzg2l_irqc_data), GFP_KERNEL); if (!rzg2l_irqc_data) return -ENOMEM; rzg2l_irqc_data->irqchip = irq_chip; rzg2l_irqc_data->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL); if (IS_ERR(rzg2l_irqc_data->base)) return PTR_ERR(rzg2l_irqc_data->base); If you drop the reference on the device, you are allowing it to be removed, and everything the driver cares about to disappear behind its back. I can't really see how this is safe, because in general, removing an interrupt controller driver from the system is a pretty bad idea, and I'm worried that's you are implicitly enabling. M. -- Without deviation from the norm, progress is not possible.