Netdev List
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: nishkadg.linux@gmail.com
Cc: grygorii.strashko@ti.com, ivan.khoronzhuk@linaro.org,
	linux-omap@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] net: ethernet: ti: cpsw: Add of_node_put() before return and break
Date: Tue, 16 Jul 2019 12:37:23 -0700 (PDT)	[thread overview]
Message-ID: <20190716.123723.2173742343657007091.davem@davemloft.net> (raw)
In-Reply-To: <20190716054843.2957-1-nishkadg.linux@gmail.com>

From: Nishka Dasgupta <nishkadg.linux@gmail.com>
Date: Tue, 16 Jul 2019 11:18:43 +0530

> Each iteration of for_each_available_child_of_node puts the previous
> node, but in the case of a return or break from the middle of the loop,
> there is no put, thus causing a memory leak.

What an incredible terribly designed loop macro, this
for_each_available_child_of_node () thing is.

A macro with non-trivial, invisible, side effects.  It requires
special handling of reference counting of objects if the loop is
terminated early.

This is so error prone.  Is it any wonder we have to go through the
entire tree fixing up nearly every use of this thing?

Instead of looking at the automated analysis of this and saying "great
here are all of these places where I can fix bugs", I would instead
appreicate it if the reaction was more like "this interface is
obviously impossible to use in a non-error-prone fashion, we should
fix it."

I guess I have no choice but to apply your fixes, but the larger issue
must be addressed instead.

      reply	other threads:[~2019-07-16 19:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16  5:48 [PATCH] net: ethernet: ti: cpsw: Add of_node_put() before return and break Nishka Dasgupta
2019-07-16 19:37 ` David Miller [this message]

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=20190716.123723.2173742343657007091.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=grygorii.strashko@ti.com \
    --cc=ivan.khoronzhuk@linaro.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nishkadg.linux@gmail.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