From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 7D770422536 for ; Mon, 3 Aug 2026 13:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785765595; cv=none; b=pBe/6jTye6u20WRd7DxxiXAoPM4XFX0bSig/XlN+i3alK7IByBj8ElxoPnE4PtX/YxQKmlJpj6YrVFlq6TlBYm6yEeG9qYyBcEsKQvuz8V6w/BtKwhztAheTsQHwdflpHliwaQQyX49s8hAfGs7e2fsAqoJgNc1dsXxlQgTAuzw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785765595; c=relaxed/simple; bh=Xm/7DtiEMg1IjVRIDD0Dmnqy+tWy/4RQwD2wLYgsQ1U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MPPCrBIjCo03cchZM2KqGYAVhnuHCy6oy+n+noCe/4owQtRIhHIb2l6GrH8IQKoCt3nIVimUw5vrEWS7T/WwVeM6CPUsJUNhAyBR03E/HwrZd0OkiCRvpnuZhxfsCyya2Zdcj2f0amaTlzkzN0qOi/A5L/rGfjMgC6Kh7HZJ+Tk= 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=a/mbDd7b; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a/mbDd7b" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-38759bcd877so3027354a91.2 for ; Mon, 03 Aug 2026 06:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785765594; x=1786370394; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=r+pksryrxLXLGb/sclyi3ItCIZaPNjNevdntxR0DkJM=; b=a/mbDd7bmFL43HNAgNHEUc1w4UxVNQekw3kRIPkcmw0jd4czbJM3qGRb00uLFJ2DQp CxMzHB0py5bQwn1wmtmLnEpRlJ66ba6Z6Q33NXYSM8eHKaiCfsDMo/2wPIRRmB5hel7O z5KoVMFQEV+/PY4RB1VPh3Rys//oGNwFRyIXJlcfiOhUSAlrgHvw6Dft8jxI7A7X3H7u LJqOdP8Ibu/9xdN4YuV/oc36AxSosWrH8PrAkvT0+bzVfzJH9bE+mV9Qgr5Flb3iqRPK szgUs33uuKpWraDYCaplasMQGkNfOd7tnPn2f1aegzWzJE4ZLI7CHxxnliq9i0REMH8k MYjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785765594; x=1786370394; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=r+pksryrxLXLGb/sclyi3ItCIZaPNjNevdntxR0DkJM=; b=bsg0tKFyPog1Wt+3C2tG10sa/lp/jmoDtY4DUG55o3HvL1XlarwBtQuKbGXn0GJIve AkdMx1sb+b6EnKIvhsSTX4XQw1Qu1PlxiD53benFbkInPM2lGiFFjtnCU7/yHZ8VfFy7 NwkUeeowAsCRhXf6lEGkgFx8HJFlyHAbNqREXY1rJU3bCgbWozrf4tFPaIsVGM+vqpwb CIiZ87pSZCNpKmtbNpS//FfonV+Jje+/bxRDvyy1gZ3mPYuADbPheDw1BXHR0x5kkmRx b0Nn4Ir2Vrnl9Xh7gHqT53UaAquOJPmORMxAlR41aI6EgbGwhNAC2FrWMHpC25pd/NMC Jj9Q== X-Forwarded-Encrypted: i=1; AHgh+Rr61OOtEmW+6d25PBqWb58/AtkRxxaRUwTmEphaPd7GSXN0E/qcKV1Jh8GeA+r3zyU1UzNe+EY=@vger.kernel.org X-Gm-Message-State: AOJu0YwSbMjxtdwDMZpFG1hTVoEnXYhQW6dgTQ6abpt4IJtHdSF8U3WD 1aO0BmKEpWChMgFg1ds6iRIhbGeBMw97PPTZ7f/sSwFPmzKqSa4lauM= X-Gm-Gg: AR+sD11uQ1NfbO2JxVwZjAZ9A4JeU+y3itfSkII5CZxFbieEupzt0gIv7GlMCni5b9T lNhn8e7uX3ZQDzNg/X5Gn2SaYgArCsHIx1V/eKG7k6aygLnUPkKQjpF0u8G8pEn72U7WWxIhfyj pHkClMPr2YOr2U9J9bVyC3/HVNQ7j1oG367/wD+kI91E9I0Z8a61S4MeCagFBFm4ioZHYp+MXWs 5sFYlrw7rIUseKnaM6/cxcdnoHMiqGBzPff6pN/zyuFI3EU/q5ERRnHg1xuzSX5cNANcqDGgCBR T124U8snVUhfTcj8d2inZHspCNzbX94ZlTVuvXpN6VAe+G1p0w1UCDP5/XkWNwI9iDI2FamTW2L qMeufopexfI8/QVNSc+ZVVuIrU8r4IFIG6fwEMBovT8vAnUMWR2GKafb5b7xDO6o+41OrOCoipj D9BjqotJpVxRS8ZUlhy33bP+fAeIpO2ibJG+epo4wXX3Znd+5AFjugM+tfHqB8B9+2La5OGD5W9 pa4+y8hlgdW5/WoGZ8OGJidtUgSkDdBfxttorYeR4pUJZixXl7ptgrYaaq5NLiFf4zOkQW2fNh9 NJgjQNe1ouDmpb/X5qz3Mlc= X-Received: by 2002:a17:90b:1d52:b0:380:540:d499 with SMTP id 98e67ed59e1d1-38fbc3fb64cmr8689147a91.6.1785765593692; Mon, 03 Aug 2026 06:59:53 -0700 (PDT) Received: from localhost.localdomain ([1.226.165.54]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38fb2ce1778sm4068946a91.15.2026.08.03.06.59.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Aug 2026 06:59:53 -0700 (PDT) From: Myeonghun Pak To: Richard Cochran Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Myeonghun Pak , Ijae Kim Subject: [PATCH net v2] ptp: fc3: register PTP clock after initialization Date: Mon, 3 Aug 2026 22:59:42 +0900 Message-ID: <20260803135942.48383-1-mhun512@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ptp_clock_register() exposes the clock to userspace. If either following initialization operation fails, probe returns and devres frees idtfc3 while the registered clock still refers to the clock information embedded in it. Complete the fallible initialization before registering the clock. Schedule the worker after registration because it requires the registered clock. This removes post-registration failures and avoids exposing a partially initialized clock. Fixes: 1ddfecafabf7 ("ptp: add FemtoClock3 Wireless as ptp hardware clock") Cc: stable@vger.kernel.org Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak --- Changes in v2: - Register the PTP clock after initialization instead of unregistering it while holding idtfc3->lock, which could deadlock with a concurrent clock operation holding the POSIX clock rwsem. drivers/ptp/ptp_fc3.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/ptp/ptp_fc3.c b/drivers/ptp/ptp_fc3.c index f0e0004..02b9739 100644 --- a/drivers/ptp/ptp_fc3.c +++ b/drivers/ptp/ptp_fc3.c @@ -665,8 +665,6 @@ static int idtfc3_init_timecounter(struct idtfc3 *idtfc3) if (err) return err; - ptp_schedule_worker(idtfc3->ptp_clock, idtfc3->tc_update_period); - return 0; } @@ -825,6 +823,14 @@ static int idtfc3_enable_ptp(struct idtfc3 *idtfc3) idtfc3->caps = idtfc3_caps; snprintf(idtfc3->caps.name, sizeof(idtfc3->caps.name), "IDT FC3W"); + err = idtfc3_set_overhead(idtfc3); + if (err) + return err; + + err = idtfc3_init_timecounter(idtfc3); + if (err) + return err; + idtfc3->ptp_clock = ptp_clock_register(&idtfc3->caps, NULL); if (IS_ERR(idtfc3->ptp_clock)) { @@ -833,13 +839,7 @@ static int idtfc3_enable_ptp(struct idtfc3 *idtfc3) return err; } - err = idtfc3_set_overhead(idtfc3); - if (err) - return err; - - err = idtfc3_init_timecounter(idtfc3); - if (err) - return err; + ptp_schedule_worker(idtfc3->ptp_clock, idtfc3->tc_update_period); dev_info(idtfc3->dev, "TIME_SYNC_CHANNEL registered as ptp%d", idtfc3->ptp_clock->index); -- 2.50.1