[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGETcx9gUG-0GW8trnC-xm5DPfXkVjgdzBg0-M+tRWhyz8fgQw@mail.gmail.com>
Date: Mon, 18 May 2020 12:47:01 -0700
From: Saravana Kannan <saravanak@...gle.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
stable <stable@...r.kernel.org>,
Android Kernel Team <kernel-team@...roid.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1] driver core: Fix memory leak when adding
SYNC_STATE_ONLY device links
On Mon, May 18, 2020 at 1:03 AM Greg Kroah-Hartman
<gregkh@...uxfoundation.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@...gle.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@...r.kernel.org
> > > Fixes: 05ef983e0d65 ("driver core: Add device link support for SYNC_STATE_ONLY flag")
> > > Signed-off-by: Saravana Kannan <saravanak@...gle.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
Powered by blists - more mailing lists