From: David Miller <davem@davemloft.net>
To: tobin@kernel.org
Cc: gregkh@linuxfoundation.org, roopa@cumulusnetworks.com,
nikolay@cumulusnetworks.com, tyhicks@canonical.com,
bridge@lists.linux-foundation.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] bridge: Fix error path for kobject_init_and_add()
Date: Fri, 10 May 2019 15:06:22 -0700 (PDT) [thread overview]
Message-ID: <20190510.150622.135840136910324302.davem@davemloft.net> (raw)
In-Reply-To: <20190510025212.10109-1-tobin@kernel.org>
From: "Tobin C. Harding" <tobin@kernel.org>
Date: Fri, 10 May 2019 12:52:12 +1000
> Currently error return from kobject_init_and_add() is not followed by a
> call to kobject_put(). This means there is a memory leak. We currently
> set p to NULL so that kfree() may be called on it as a noop, the code is
> arguably clearer if we move the kfree() up closer to where it is
> called (instead of after goto jump).
>
> Remove a goto label 'err1' and jump to call to kobject_put() in error
> return from kobject_init_and_add() fixing the memory leak. Re-name goto
> label 'put_back' to 'err1' now that we don't use err1, following current
> nomenclature (err1, err2 ...). Move call to kfree out of the error
> code at bottom of function up to closer to where memory was allocated.
> Add comment to clarify call to kfree().
>
> Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> ---
>
> v1 was a part of a set. I have dropped the other patch until I can work
> out a correct solution.
Applied and queued up for -stable, thanks.
prev parent reply other threads:[~2019-05-10 22:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-10 2:52 Tobin C. Harding
2019-05-10 2:57 ` Tobin C. Harding
2019-05-10 22:06 ` 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=20190510.150622.135840136910324302.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=bridge@lists.linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=roopa@cumulusnetworks.com \
--cc=tobin@kernel.org \
--cc=tyhicks@canonical.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
all inboxes | Powered by JetHome®