From: Vladis Dronov <vdronov@redhat.com>
To: Andrea Righi <andrea.righi@canonical.com>
Cc: Richard Cochran <richardcochran@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ptp: free ptp clock properly
Date: Wed, 4 Mar 2020 15:11:44 -0500 (EST) [thread overview]
Message-ID: <1830360600.13123996.1583352704368.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20200304175350.GB267906@xps-13>
Hello, Andrea, all,
----- Original Message -----
> From: "Andrea Righi" <andrea.righi@canonical.com>
> Subject: [PATCH] ptp: free ptp clock properly
>
> There is a bug in ptp_clock_unregister() where ptp_clock_release() can
> free up resources needed by posix_clock_unregister() to properly destroy
> a related sysfs device.
>
> Fix this by calling posix_clock_unregister() in ptp_clock_release().
Honestly, this does not seem right. The calls at PTP clock release are:
ptp_clock_unregister() -> posix_clock_unregister() -> cdev_device_del() ->
-> ... bla ... -> ptp_clock_release()
So, it looks like with this patch both posix_clock_unregister() and
ptp_clock_release() are not called at all. And it looks like the "fix" is
not removing PTP clock's cdev, i.e. leaking it and related sysfs resources.
I would guess that a kernel in question (5.3.0-40-generic) has the commit
a33121e5487b but does not have the commit 75718584cb3c, which should be
exactly fixing a docking station disconnect crash. Could you please,
check this?
Why? We have 2 crash call traces. 1) the launchpad bug 2) the email which
led to the commit 75718584cb3c creation (see Link:).
Aaaaand they are identical starting from device_release_driver_internal()
and almost to the top.
> See also:
> commit 75718584cb3c ("ptp: free ptp device pin descriptors properly").
>
> BugLink: https://bugs.launchpad.net/bugs/1864754
> Fixes: a33121e5487b ("ptp: fix the race between the release of ptp_clock and
> cdev")
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
> ---
> drivers/ptp/ptp_clock.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> index ac1f2bf9e888..12951023d0c6 100644
> --- a/drivers/ptp/ptp_clock.c
> +++ b/drivers/ptp/ptp_clock.c
> @@ -171,6 +171,7 @@ static void ptp_clock_release(struct device *dev)
> struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev);
>
> ptp_cleanup_pin_groups(ptp);
> + posix_clock_unregister(&ptp->clock);
> mutex_destroy(&ptp->tsevq_mux);
> mutex_destroy(&ptp->pincfg_mux);
> ida_simple_remove(&ptp_clocks_map, ptp->index);
> @@ -303,8 +304,6 @@ int ptp_clock_unregister(struct ptp_clock *ptp)
> if (ptp->pps_source)
> pps_unregister_source(ptp->pps_source);
>
> - posix_clock_unregister(&ptp->clock);
> -
> return 0;
> }
> EXPORT_SYMBOL(ptp_clock_unregister);
> --
> 2.25.0
Best regards,
Vladis Dronov | Red Hat, Inc. | The Core Kernel | Senior Software Engineer
next prev parent reply other threads:[~2020-03-04 20:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-04 17:53 [PATCH] ptp: free ptp clock properly Andrea Righi
2020-03-04 20:11 ` Vladis Dronov [this message]
2020-03-05 7:36 ` Andrea Righi
2020-03-05 10:47 ` Vladis Dronov
2020-03-05 10:58 ` Andrea Righi
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=1830360600.13123996.1583352704368.JavaMail.zimbra@redhat.com \
--to=vdronov@redhat.com \
--cc=andrea.righi@canonical.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@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;
as well as URLs for NNTP newsgroup(s).