From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Dilger, Andreas" <andreas.dilger@intel.com>
Cc: "Eremin, Dmitry" <dmitry.eremin@intel.com>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
"Drokin, Oleg" <oleg.drokin@intel.com>,
James Simmons <jsimmons@infradead.org>,
Dan Carpenter <dan.carpenter@oracle.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Lustre Development List <lustre-devel@lists.lustre.org>
Subject: Re: [PATCH] staging: lustre: Fix avoid intensive reconnecting for ko2iblnd patch
Date: Wed, 17 Jan 2018 15:02:16 +0100 [thread overview]
Message-ID: <20180117140216.GA5449@kroah.com> (raw)
In-Reply-To: <6D19AB36-CDDF-4743-AF46-ADF31E26B4F4@intel.com>
On Wed, Jan 17, 2018 at 12:36:19AM +0000, Dilger, Andreas wrote:
>
> > On Jan 16, 2018, at 09:56, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> >
> > On Tue, Jan 16, 2018 at 03:01:49PM +0000, Eremin, Dmitry wrote:
> >> In the original commit 4d99b2581effe115376402e710fbcb1c3c073769
> >
> > Please use the documented way to write this:
> > 4d99b2581eff ("staging: lustre: avoid intensive reconnecting for ko2iblnd")
> >
>
> >> was missed one hunk. Added it now to avoid issue with use after free.
> >
> > And I do not understand this commit message at all.
> >
> >> Signed-off-by: Dmitry Eremin <Dmitry.Eremin@intel.com>
> >> ---
> >> drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 3 ++-
> >> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> >> index 2ebc484..a15a625 100644
> >> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> >> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> >> @@ -890,7 +890,8 @@ void kiblnd_destroy_conn(struct kib_conn *conn, bool free_conn)
> >> atomic_dec(&net->ibn_nconns);
> >> }
> >>
> >> - kfree(conn);
> >> + if (free_conn)
> >> + kfree(conn);
> >
> > This looks really odd, don't you think?
>
> I'm not sure what the objection is here? There is an argument to this
> this function named "free_conn" which determines if the structure should
> be freed, or if the network connection is just being torn down and
> reconnected.
At first glance it really looks like the normal pattern of:
if (foo_ptr)
kfree(foo_ptr);
right?
If you don't want to free the variable, set it to NULL.
Even then, this is a horrible function, you should have 2 different
ones:
kiblnd_destroy_conn(...)
kiblnd_free_conn()
and then just free the variable in the free_conn() function if you were
going to set the free_conn variable, right?
That way no odd code paths are taken, and it's obvious what you are
doing just by reading the code at the callsite.
thanks,
greg k-h
next prev parent reply other threads:[~2018-01-17 14:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1516114161-27679-1-git-send-email-Dmitry.Eremin@intel.com>
2018-01-16 15:01 ` Eremin, Dmitry
2018-01-16 16:56 ` Greg Kroah-Hartman
2018-01-17 0:36 ` Dilger, Andreas
2018-01-17 14:02 ` Greg Kroah-Hartman [this message]
2018-01-16 18:02 ` Eremin, Dmitry
2018-01-22 10:39 ` Greg Kroah-Hartman
2018-01-24 12:45 ` [PATCH v2] " Dmitry Eremin
2018-01-24 14:14 ` [PATCH v3] staging: lustre: separate a connection destroy from free struct kib_conn Dmitry Eremin
2018-01-24 14:29 ` Greg Kroah-Hartman
2018-01-25 13:51 ` [PATCH v4] " Dmitry Eremin
2018-01-26 4:34 ` Dilger, Andreas
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=20180117140216.GA5449@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=andreas.dilger@intel.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=dmitry.eremin@intel.com \
--cc=jsimmons@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=oleg.drokin@intel.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®