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 74DFE166F39; Sun, 6 Oct 2024 15:53:45 +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=1728230025; cv=none; b=Kr5xsxVyxwsrmWxROtJV7aQtLkKpPc799YM2xQGxfGRF9Z9wEfFtqH67RLjD9qkO9dI7Xd6pI8Kprdp7ndRmTsdJwtnx0MvAbrNZz2t+dAtwhBqSwfP869H0FPo5YbqeQrHvMlAXpPlU8k0jkIMEKJIF3W0omCQEhqnamKEeNho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728230025; c=relaxed/simple; bh=vo0ma4ptxCvY6yxU5DR1FiiRD2juX28g/eluGxAZNuI=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=qfbL4KYTNaNwx7dQ4FMSGmXiPSMg3IH/RnsEK7+u0PDXQhnBMdoGCKnL+Mey7eTNXPhSUmD5jt5QY0yD4/IwTS9XUFzZE3L9ixR07lNDi0M1Z98czcdfYBp9E8+U50czSZxRM2amkshdkNGYLnWrMq31XMI9n58vPu5szovH6A8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rJ3bmzvT; 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="rJ3bmzvT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECBBBC4CEC5; Sun, 6 Oct 2024 15:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728230025; bh=vo0ma4ptxCvY6yxU5DR1FiiRD2juX28g/eluGxAZNuI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rJ3bmzvTOe1HGdSymAaItg/QpNOEcr2N7XzMMErjodQWo4/k8bKx8SGEeoUAIhKKU xFjCNOUJ43/CH4lDnja1Q0Rw5DOe7M7ZRBhzmZEpfc4ng6nlPPRvIS74JFDxiQBGZK 1M/m5SHZDYPhnGeUVn8xbZCBwcPhQMYq+hOLvAnorombFqjub2Zidt3ue0dSlrJIE6 Az5QzdI7bH+qgf7Y2AjlWfo9tHALGZoygXqZvrHThgJBxpeKy+xqDPCRWsFCvtotaV Fx2HACQq/GnXuFKcayr+eOrEZryc0Nc7Agjr2hiWvjC1lRUkVXI8EbkeOqMLWS9NdS tEAZSHeFa8PRA== 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 1sxTZm-000o7I-PJ; Sun, 06 Oct 2024 16:53:42 +0100 Date: Sun, 06 Oct 2024 16:53:42 +0100 Message-ID: <861q0t6xdl.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> <86frph6jir.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 Tue, 01 Oct 2024 12:54:30 +0100, Fabrizio Castro wrote: > > Hi Marc, > > thank you for your reply. > > > From: Marc Zyngier > > Sent: Monday, September 30, 2024 8:15 PM > > To: Fabrizio Castro > > Subject: Re: [PATCH] irqchip/renesas-rzg2l: Fix missing put_device > > > > 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. > > Thanks for the explanation. I think this means that we don't need to > put the device on the successful path, but we still need to put the > device on the error path. That I would agree. > If I take out the put_device for the successful path, and I run make > coccicheck, I get the below: > drivers/irqchip/irq-renesas-rzg2l.c:601:1-7: ERROR: missing > put_device; call of_find_device_by_node on line 538, but without a > corresponding object release within this function. > > Can I just ignore it? My general approach is that these scripts are not a substitute for reasoning, and in this instance, the advise seems pretty misplaced. I would suggest you add a comment to keep the next script kiddie at bay. M. -- Without deviation from the norm, progress is not possible.