Article View: linux.kernel.netdev
Article #3759[PATCH net v4 2/5] ptp: unwind partially completed virtual clock creation
From: James Hilliard
Date: Thu, 15 Oct 2026 23:33
Date: Thu, 15 Oct 2026 23:33
51 lines
10071 bytes
10071 bytes
n_vclocks_store() publishes the new clock count only after every child
has been registered. If a later registration fails, it returns without
unregistering the children already created by that request. Those clocks
are left out of n_vclocks, and a subsequent request can overwrite their
index entries without removing them.
Unregister the newly created children in reverse order and clear their
index entries on failure. Leave the previously installed clocks and
their count unchanged. The n_vclocks mutex serializes this rollback with
other sysfs changes, and parent removal drains the store before walking
the children.
This was found by code inspection while adding initial PHC sample error
handling to virtual clock registration.
Fixes: 73f37068d540 ("ptp: support ptp physical/virtual clocks conversion")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/ptp/ptp_sysfs.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
index 53388b123198..fabc1c9b1752 100644
--- a/drivers/ptp/ptp_sysfs.c
+++ b/drivers/ptp/ptp_sysfs.c
@@ -225,7 +225,7 @@ static ssize_t n_vclocks_store(struct device *dev,
for (i = 0; i < num - ptp->n_vclocks; i++) {
vclock = ptp_vclock_register(ptp);
if (!vclock)
- goto out;
+ goto err_register;
*(ptp->vclock_index + ptp->n_vclocks + i) =
vclock->clock->index;
@@ -257,6 +257,12 @@ static ssize_t n_vclocks_store(struct device *dev,
mutex_unlock(&ptp->n_vclocks_mux);
return count;
+err_register:
+ num = i;
+ if (num)
+ device_for_each_child_reverse(dev, &num, unregister_vclock);
+ for (num = 0; num < i; num++)
+ ptp->vclock_index[ptp->n_vclocks + num] = -1;
out:
mutex_unlock(&ptp->n_vclocks_mux);
return err;
--
2.53.0
Technical Details
Message-ID:
<20261015-ptp-vclock-sampling-v4-2-cba6ffc8ceb6@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346974-linux-kernel-netdev=dewy.ruReferences:
<20261015-ptp-vclock-sampling-v4-0-cba6ffc8ceb6@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346974-linux-kernel-netdev=dewy.ru
From: james.hilliard1@gmail.com (James Hilliard)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v4 2/5] ptp: unwind partially completed virtual clock
creation
Date: Thu, 15 Oct 2026 17:33:32 -0600
Organization: Usenet Network
Message-ID: <20261015-ptp-vclock-sampling-v4-2-cba6ffc8ceb6@gmail.com>
References: <20261015-ptp-vclock-sampling-v4-0-cba6ffc8ceb6@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="2645236"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:hAm2CLML9IdpIKvwtFYLI3u2LJc= sha256:DuV7cRtseS80LKawB3VbxRdC1yMZeoaK9z7QPAuknjI=
sha1:OUH0tjpn43Su6INFeXzqUbotRf0= sha256:Zdyj9tMpmuEDfN/k6XZj7NB3GcwkbrbTbFQPxLPZ7II=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 780611103EF; Fri, 16 Oct 2026 02:34:15 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.048
X-Spam-Status: No, score=-2.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FORGED_GMAIL_RCVD=1,
FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id NSKY-9q2R1Hi;
Fri, 16 Oct 2026 02:34:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-346974-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 2304C1103CA; Fri, 16 Oct 2026 02:34:04 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by tor.lore.kernel.org (Postfix) with ESMTP id A9F733C9CC; Thu, 15 Oct 2026 23:33:46 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id D69684E0B79;
Thu, 15 Oct 2026 23:33:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BuJwfZa+"
X-Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 461BE4D9561
for <netdev@vger.kernel.org>; Thu, 15 Oct 2026 23:33:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1792107225; cv=none; b=ExH0k1fCzoUEMUVd6MO7RIa03U/btMTCmM5Zqkz9wAXkVa0fOwnIE0dtP1JEXuNgKdVMHe9gFrMu/lVQ6d7Z+5//DaVHTzPT9CRM1TAileXuuJent3Bc7U175QKwdqwSwpKScU7aV31dXetoE1eyYRQ88lJS16h+IGeET2WmGe4=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1792107225; c=relaxed/simple;
bh=GrTN2b5PpfqmbfLLMqSYA4B6Q1Ro+NBdw8xoIri7aK0=;
h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:
In-Reply-To:To:Cc; b=uTLUg0VtGxqFn0hh2cMJL5qoBb3hNncIJAHRHEZsgVaTEumQ6FuMGQ1GzJrMQJpi9P5D4o25TLeXTfeqJMzvlvuxtpWhLZ7/41WtgVoGa3aQf5HwjFp2lVt9ZOuaAW20FdkDvZAK0CqyQrKdPcWh5tB8hROijq3z5PJSWZRLLPA=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BuJwfZa+; arc=none smtp.client-ip=209.85.161.49
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-6e560e00a86so4055413eaf.1
for <netdev@vger.kernel.org>; Thu, 15 Oct 2026 16:33:42 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792107221; x=1792712021; darn=vger.kernel.org;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=dOGTVagpmg3SkovNg8gY9NJcdR0snicKiJ3IvwwYIZg=;
b=BuJwfZa+frL9anoe1a/YGLllVJgn0irp7JXNwT/GqJa2xxm5jLJbQRK40MzM4/gKwt
Wn+BDuWoNXAmyWouZMPgqqfKaqFpiBIsr0fWgVkqeMJXlCkgYhUBmzCXG6wlazTyjm0+
hKyfs7HJDjYFOYqwm0VOmIKooUMR2e2HSdXVbiGG8keil9tWw4bNW1PmdLZZe7hWmWfx
DaGNURWOSqNCLFD4ZdR78oJdxTDv84XLJ07EfAnn6n1UMcnrHsZT65B5W3zx270EvIDJ
/MEtntWBw+H6wocoC+lOjQqdhmo8sn4AiqCIxExT++wyfbSYp0/AyFD536TYxi5M9X1d
e8dQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792107221; x=1792712021;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=dOGTVagpmg3SkovNg8gY9NJcdR0snicKiJ3IvwwYIZg=;
b=UgNq0mQYrqgxYDmRYTjYe1ZRtV1g+MGKAfQOnK1/97oc84/Qak2jaVQka6mwLlG2/H
TisklB8DhatobKjXT2Yh/l6DZhMfEpSgKBeCH2jZnwvnsWZpNLLOU7HSZWkWjxkqpvGT
1lsnB1Bm9Qzp3BDzWZKGkTKCdlB6jKfhEFT0rEEFsRF+2QVpjtxaAqeAPEzSAJW6RjmO
3WoLaTpv0tpGYCY/mzny4BB9XMBvrkrGNzsW4YbqvTrn4q70i6eeDgfJ9/xqfk45j3+U
kcCQWkvknWwNMt6qQcH099Bbw7ylvUp6y8Vh2cjdWRjRuHfG7+qFHEVN+2QVK6vdy+WI
RiGQ==
X-Gm-Message-State: AFq9FYLAn2U/R1G/bGQvisETGfDrK+1uicaIdp3AcK721+vNO39dJkgn
1JkMkdS+1dtq23Ceq/TN2e9Oynv04rfugfRXirWvQj5FJzDUCNobavSL
X-Gm-Gg: AYBFou2hfBJNgpozm1f8FB7CxX3ulyrWcW0t/yXvWgVmPm73JHofwysJ/uYQCx5i1yT
hYq4CPdqDcj+LDPUXzyqv/zThRAeBNHjXZARJxHKB3l01z8cbsPmyYFcC6dQSdZ6CCk//+G5Je/
8HZzXLYixEJKCdfKzO92un7EB0UfDn55LJ/J1PvuDuvWzTxCbagIUDReIdJbPmpzhkm4US1ORnw
rFoUyw+BYWgBwOUWVn1fLp8uy+iczWjm5a38akKwIHaQbn2AoEJBf/nBrbsdKDtWo+CAbXVf0li
Y447xTbuj/nOxWrI/+uoCbMtxrIamk9lHTuhmY8wTzb0a7+CZ753BAL1YHQ2ga1lPoGphUyeYgD
QJOxL1nWJUixPH/CDb5+XgJuMjymYcBYHfTuH8jYmZKGq0m26ylJTtkKz4bBX1QP2Nzfx6dn0Xo
ssoRcJ2V6wq1x9l/fPKQlUhSlvKmo5TVIcYuHZN1ITu5zjc0hD6RNp+pcupIY2P1yzeSUaSz9Y+
06eb9WyLzRVzOnrAYVfAZeEwAi2vyXlG1lizgzpzwbQ0K4iao1eHEfNElQCujDBXDppYHb/m4Ci
5AG+xGRVJQhplO7Agx45NS2ToabOX3KXH8Xc/mjO3fRlyf2J42u6zunpIJK9BV7ukEX3ET+dman
JAc9OxdX3jjuUfAeazg5fOF68gFtqdlvm
X-Received: by 2002:a4a:e907:0:b0:6be:1570:73b6 with SMTP id 006d021491bc7-6ef0e9dac96mr13517324eaf.20.1792107221207;
Thu, 15 Oct 2026 16:33:41 -0700 (PDT)
X-Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49])
by smtp.gmail.com with ESMTPSA id 006d021491bc7-70188bd9ecdsm525519eaf.2.2026.10.15.16.33.39
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 15 Oct 2026 16:33:40 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-In-Reply-To: <20261015-ptp-vclock-sampling-v4-0-cba6ffc8ceb6@gmail.com>
X-Cc: Eric Dumazet <edumazet@kernel.org>,
"David S. Miller" <davem@davemloft.net>, linux-kernel@vger.kernel.org,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
James Hilliard <james.hilliard1@gmail.com>
X-Mailer: b4 0.15.2