From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379722; b=3mKn82h+MdGB0hgr5YPlzCuJCwwv7sN6XCjK8JE/8SKMyZlQrl2HTBlvTgsN3NBtiHPb mD3iobiWKchUJS0n2Cc3nKdjdSAmyOKUNEeDQXfyhKTy1R9b14ggk3QisZzTrpSnUv2Kh bymuqGx9QGuN5a2OEJRcAH02Dc28792Z3aCXT1oEjxdZG0bUfeHYORF7PYmDa2pcf0H4v QZBrNdP+e8/w/8dedNxrIWnhqUdZ1/ulXRMh6ev6Ww36eFP7MLmbg5mARDzU0wyMI/Wdc WQFU+GqyyYJoJm/i4RDGxCN+deA6xGNne5ZksoQ5RnghIjx3rdL5xvzI5oj6RKfCGqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379722; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=qCaX76E5UZu2iIurBjDIJ5FMeKQqA/fda9tUaF5b24A=; b=Z9VerRnCNCwjyPSU6ly3CAck2PVQthg/jsozq1EvlvwRsNQc2k7d/ULkgE5WWx4B14p7 tQyx0Bk3MU9sw+Jqx0AEdQkQwcaRBn+uUuLcMJQV8N2tn5AgNdlQUtxHGag2WfOW3VMqx DLa5vXkr9D9i0zSBE5YwTuhXDebUFXqwr7jHoTsPdUgZFV50HDwfdOsShPwSHhNAGk5c+ 3TSHqVxWUPoW3ROagGHAKjfX7JtRbdNXleqZ6eJJ59NxkHnga7S+SCDg72dejFETy3feK iSUKzKPegokGF7yKEyn65SHOsg6WQNu/Y2HG2cw2S0oEA67XkQXCorgxyUZ4mbwyAqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BfPw6FmO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89770606A322; Fri, 4 Dec 2026 10:22:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BfPw6FmO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07A841F000CE; Fri, 4 Dec 2026 10:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379722; bh=qCaX76E5UZu2iIurBjDIJ5FMeKQqA/fda9tUaF5b24A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BfPw6FmOUQd3by+tsfpGmF7YEwIwCAUC5yNz0d463YpAjizbRkgeTMoZW5hA/LVLA wY1ME1+HOneiY25vTzKRhWj+kA+FwUuqh5HyJKD1HcGmymtJTLVcyeeTpfYNQerl5N S7NaQIv2Eg8HHfdpcg7JytzzJtE19kE1+yULel+k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, James Hilliard , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0059/1167] ptp: unwind partially completed virtual clock creation Date: Fri, 4 Dec 2026 18:51:26 +0900 Message-ID: <20261204100703.618609413@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: James Hilliard [ Upstream commit 3dea778260e3dddf30651a6913d87a42861346a2 ] 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 Link: https://patch.msgid.link/20261026-ptp-vclock-sampling-v6-2-e705612541f1@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- 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 5f81b06ebebc5..31e176e91d78c 100644 --- a/drivers/ptp/ptp_sysfs.c +++ b/drivers/ptp/ptp_sysfs.c @@ -223,7 +223,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; @@ -255,6 +255,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