From: "Leonardo Brás" <leobras.c@gmail.com>
To: Wan Jiabing <wanjiabing@vivo.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
Frederic Barrat <fbarrat@linux.ibm.com>,
David Gibson <david@gibson.dropbear.id.au>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: kael_w@yeah.net
Subject: Re: [PATCH] powerpc/pseries/iommu: Add of_node_put() before break
Date: Thu, 14 Oct 2021 14:32:43 -0300 [thread overview]
Message-ID: <52f1cec812e81b45dbbc28eef3cd90cc9c0a90ae.camel@gmail.com> (raw)
In-Reply-To: <20211014075624.16344-1-wanjiabing@vivo.com>
Hello Wan, thank you for this patch.
On Thu, 2021-10-14 at 03:56 -0400, Wan Jiabing wrote:
> Fix following coccicheck warning:
>
> ./arch/powerpc/platforms/pseries/iommu.c:924:1-28: WARNING: Function
> for_each_node_with_property should have of_node_put() before break
>
> Early exits from for_each_node_with_property should decrement the
> node reference counter.
Yeah, it makes sense to me.
for_each_node_with_property calls of_find_node_with_property() at each
step, which ends up calling of_node_put() after using each node.
Introducing this break caused this of_node_put not to happen to the
last node, so IIUC this patch fixes a possible issue if kzalloc() fails
in ddw_list_new_entry().
Another option would be s/break/continue here, but it does not make
sense to keep trying next nodes if there is no memory to allocate for a
struct dma_win (4 pointers).
On the other hard, failing on allocating such small space should not
happen often (if it will ever happen), so a 'continue' here makes code
simpler.
Anyway, FWIW:
Reviewed-by: Leonardo Bras <leobras.c@gmail.com>
Best regards,
Leo
>
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
> arch/powerpc/platforms/pseries/iommu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/pseries/iommu.c
> b/arch/powerpc/platforms/pseries/iommu.c
> index 269f61d519c2..c140aa683f66 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -929,8 +929,10 @@ static void find_existing_ddw_windows_named(const
> char *name)
> }
>
> window = ddw_list_new_entry(pdn, dma64);
> - if (!window)
> + if (!window) {
> + of_node_put(pdn);
> break;
> + }
>
> spin_lock(&dma_win_list_lock);
> list_add(&window->list, &dma_win_list);
next prev parent reply other threads:[~2021-10-14 17:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 7:56 [PATCH] powerpc/pseries/iommu: Add of_node_put() before break Wan Jiabing
2021-10-14 17:32 ` Leonardo Brás [this message]
2021-11-02 10:11 ` Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52f1cec812e81b45dbbc28eef3cd90cc9c0a90ae.camel@gmail.com \
--to=leobras.c@gmail.com \
--cc=aik@ozlabs.ru \
--cc=benh@kernel.crashing.org \
--cc=david@gibson.dropbear.id.au \
--cc=fbarrat@linux.ibm.com \
--cc=kael_w@yeah.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=wanjiabing@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).