From: Ahmad Byagowi <ahmadexp@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com,
vadim.fedorenko@linux.dev
Subject: [PATCH net v7 1/2] ptp: serialize sysfs enable requests with ioctl paths
Date: Fri, 27 Nov 2026 11:20:36 -0800 [thread overview]
Message-ID: <20261127-timecard-core-v7-1-ahmadexp@gmail.com> (raw)
In-Reply-To: <20261127-timecard-core-v7-0-ahmadexp@gmail.com>
Drivers may call ptp_find_pin() from their enable callback; that helper
requires the caller to hold pincfg_mux. The ioctl paths hold the lock,
but the EXTTS, PPS and periodic-output sysfs stores do not.
Take pincfg_mux around the three sysfs callbacks. Leave existing
validation, permission checks and callback error handling unchanged.
Return -ERESTARTSYS if lock acquisition is interrupted.
Developed with coding-assistant support during review and validation.
Fixes: 62582a7ee783 ("ptp: Avoid deadlocks in the programmable pin code.")
Link: https://lore.kernel.org/r/179579937722.3135.2568812643544816671@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
drivers/ptp/ptp_sysfs.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
index 8e0e0aa09981..90fdddc1e6a7 100644
--- a/drivers/ptp/ptp_sysfs.c
+++ b/drivers/ptp/ptp_sysfs.c
@@ -60,7 +60,10 @@ static ssize_t extts_enable_store(struct device *dev,
if (req.extts.index >= ops->n_ext_ts)
goto out;
+ if (mutex_lock_interruptible(&ptp->pincfg_mux))
+ return -ERESTARTSYS;
err = ops->enable(ops, &req, enable ? 1 : 0);
+ mutex_unlock(&ptp->pincfg_mux);
if (err)
goto out;
@@ -130,7 +133,10 @@ static ssize_t period_store(struct device *dev,
goto out;
enable = req.perout.period.sec || req.perout.period.nsec;
+ if (mutex_lock_interruptible(&ptp->pincfg_mux))
+ return -ERESTARTSYS;
err = ops->enable(ops, &req, enable);
+ mutex_unlock(&ptp->pincfg_mux);
if (err)
goto out;
@@ -157,7 +163,10 @@ static ssize_t pps_enable_store(struct device *dev,
if (cnt != 1)
goto out;
+ if (mutex_lock_interruptible(&ptp->pincfg_mux))
+ return -ERESTARTSYS;
err = ops->enable(ops, &req, enable ? 1 : 0);
+ mutex_unlock(&ptp->pincfg_mux);
if (err)
goto out;
base-commit: 4392bb809812ac79449cd0cf1f5e00469ee102d1
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-11-27 19:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 19:20 [PATCH net v7 0/2] ptp: serialize requests and stop active EXTTS Ahmad Byagowi
2026-11-27 19:20 ` Ahmad Byagowi [this message]
2026-11-27 19:20 ` [PATCH net v7 2/2] ptp: shut down enabled unassigned EXTTS channels on unregister Ahmad Byagowi
2026-11-27 19:24 ` [PATCH net v7 0/2] ptp: serialize requests and stop active EXTTS netdev-bot+sinfo
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=20261127-timecard-core-v7-1-ahmadexp@gmail.com \
--to=ahmadexp@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.