linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saravana Kannan <saravanak@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	stable <stable@vger.kernel.org>,
	Android Kernel Team <kernel-team@android.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] driver core: Fix memory leak when adding SYNC_STATE_ONLY device links
Date: Mon, 18 May 2020 12:47:01 -0700	[thread overview]
Message-ID: <CAGETcx9gUG-0GW8trnC-xm5DPfXkVjgdzBg0-M+tRWhyz8fgQw@mail.gmail.com> (raw)
In-Reply-To: <20200518080327.GA3126260@kroah.com>

On Mon, May 18, 2020 at 1:03 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Mon, May 18, 2020 at 12:48:42AM -0700, Saravana Kannan wrote:
> > On Sat, May 16, 2020 at 1:07 AM Saravana Kannan <saravanak@google.com> wrote:
> > >
> > > When SYNC_STATE_ONLY support was added in commit 05ef983e0d65 ("driver
> > > core: Add device link support for SYNC_STATE_ONLY flag"),
> > > device_link_add() incorrectly skipped adding the new SYNC_STATE_ONLY
> > > device link to the supplier's and consumer's "device link" list. So the
> > > "device link" is lost forever from driver core if the caller didn't keep
> > > track of it (typically isn't expected to).
> > >
> > > If the same SYNC_STATE_ONLY device link is created again using
> > > device_link_add(), instead of returning the pointer to the previously
> > > created device link, a new device link is created and returned. This can
> > > cause memory leaks in conjunction with fw_devlinks.
> > >
> > > Cc: stable@vger.kernel.org
> > > Fixes: 05ef983e0d65 ("driver core: Add device link support for SYNC_STATE_ONLY flag")
> > > Signed-off-by: Saravana Kannan <saravanak@google.com>
> >
> > Greg/Rafael,
> >
> > This patch causes a warning for SYNC_STATE_ONLY links because they
> > allow consumers to probe before suppliers but the device link
> > status/state change code wasn't written with that possibility in mind.
> > So I need to fix up that warning or state change code.
>
> What type of warning happens?

The WARN_ON(link->status != DL_STATE_CONSUMER_PROBE); inside
device_links_driver_bound().

>
> > Depending on how urgent you think memory leak fixes are, you can take
> > it as is for now and I can send a separate patch to fix the
> > warning/state change code later. Or if we can sit on this memory leak
> > for a week, I might be able to fix the warning before then.
>
> memory leaks are not ok, but neither is adding runtime warnings.  Any
> chance we can't just get a fix for both?  :)

Don't pick up this patch. I think I have a fix that fixes the memory
leak without warnings that also coincidentally frees up some memory.
Testing it.

-Saravana

  reply	other threads:[~2020-05-18 19:47 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-16  8:07 [PATCH v1] driver core: Fix memory leak when adding SYNC_STATE_ONLY device links Saravana Kannan
2020-05-18  7:48 ` Saravana Kannan
2020-05-18  8:03   ` Greg Kroah-Hartman
2020-05-18 19:47     ` Saravana Kannan [this message]
2020-05-19  3:00     ` [PATCH v2] driver core: Fix SYNC_STATE_ONLY device link implementation Saravana Kannan
2020-05-19  5:48       ` Greg Kroah-Hartman
2020-05-19  6:30     ` [PATCH v3] " Saravana Kannan
2020-05-19 10:47       ` Rafael J. Wysocki
2020-05-22 18:41       ` Michael Walle
2020-05-22 22:21         ` Saravana Kannan
2020-05-22 22:47           ` Michael Walle
2020-05-25 11:31             ` Michael Walle
2020-05-25 18:39               ` Saravana Kannan
2020-05-25 19:04                 ` Michael Walle
2020-05-25 21:24                   ` Saravana Kannan
2020-05-25 21:38                     ` Michael Walle
2020-05-26  7:05                       ` [PATCH v1] driver core: Update device link status correctly for SYNC_STATE_ONLY links Saravana Kannan
2020-05-26  7:07                         ` Saravana Kannan
2020-05-26 11:04                           ` Michael Walle
2020-05-26 18:08                             ` Saravana Kannan
2020-05-26  8:28                         ` Rafael J. Wysocki
2020-05-26 19:43                       ` [PATCH v2] " Saravana Kannan
2020-05-26 21:13                         ` Michael Walle
2020-05-26 21:45                           ` Saravana Kannan
2020-05-26 21:53                             ` Michael Walle
2020-05-26 22:00                               ` Saravana Kannan
2020-05-26 22:09                       ` [PATCH v3] " Saravana Kannan
2020-05-27  8:26                         ` Rafael J. Wysocki
2020-05-28 16:09                           ` Saravana Kannan

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=CAGETcx9gUG-0GW8trnC-xm5DPfXkVjgdzBg0-M+tRWhyz8fgQw@mail.gmail.com \
    --to=saravanak@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=stable@vger.kernel.org \
    /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).