From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 081973E9287 for ; Fri, 26 Jun 2026 09:34:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782466462; cv=none; b=hQeEQG2f1Vwbkbe4sx1KFVI/Fr1TENxWxE1aUoJnCJnvAkYaFuO+z+bcjZ82QDeeDQr1MN1UBdzdYNkjzwwnkyVOf+A/9XJuMgBVrdSCj74EVTCzbnZMjcKlXegaZGAA4d2cDWiVQhKH06C/OxCZtfDeLiilGnyo/7GYekEsTAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782466462; c=relaxed/simple; bh=l7M8Rv1FX6tc7M6wlAUtVT3zV3ehj2x0TDhS7wf037I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=il90d3lluZoGV0WjUjogBJ05LiIcm6xrd6wLiF4m0OeFsx8OSDch1WYPbqvPo/z8YDA2dzQul9wsF0Eu/S2P1NrfCHYHZgfr7arpAtsEhUI6eg1I9iVPaATeDUOgea2yLpyMy0FwMFQ6OyA8TMDIzpQ48/ZCpPUMJac9cFCC8Kg= 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=nC+HOWQQ; arc=none smtp.client-ip=209.85.214.172 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="nC+HOWQQ" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2c7ed7718f9so6167455ad.2 for ; Fri, 26 Jun 2026 02:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782466458; x=1783071258; 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; bh=aKllfYEV0UIxS9YR+qG1P28UUyEJha52iUC/4n2PQK4=; b=nC+HOWQQ9d66MDf/bNNaN0jY6P/P6zjdbm8Pvm+lV91sEkqxkqmPlmGmEazxRGk2+u pdnKQtrId1YUiu3C/Eu2RGKFJEtnD31010m/4Hur+WmxBO1g5lbInO0SPPK3J2lUDfdu IYEvidklxMFQRShVIbTGaYNyL3a7Rre6UVQsTSfVG77reAnobbELv7e8xxNfXX31Crxh KzuNpi0avVCbVHN1OJB7y5DI48xtwKwSxqUAvCnOT2NTsWeafOZ+VboxnPiB9GKM5tCb PxOeuHIAcejzudI4Pfg9j1tLaoYeuvlACtMZipmvvDfJrd+hVXAUqz8Dij/w/NFhEAuJ aKIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782466458; x=1783071258; 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; bh=aKllfYEV0UIxS9YR+qG1P28UUyEJha52iUC/4n2PQK4=; b=E69+15xLzKoGQSeBkP5H2OuZyNk3xbLSIsMbTUugUKNDzdIdNFKEjqdtK6XkARgo0d +z7VRvAbA2aBpq9K8LY4+eh4mimFBcmWGYAoq7kpEjuZ3w2G8Gwk9FluBmSW0fU7rf++ hG8Heds2jZLOvK2CSnbctRFte8KgVCdEVwZuBQV5rItJBJhmtNWTJi1do4ZCTQkUgPO1 Q2psp7vHcqy4Qf9r/s5voKLrHYFjqr6/JlR/qeD+9zgJdrZ3DoWl0v4E4NQBZPgs2S3z rw8L1tGzzPPqjVd+X3Mn6C/ZHfgykTTFyRlVqeD77m1WnLlBoSsFc8niV73NdPltLXWT rhPQ== X-Forwarded-Encrypted: i=1; AHgh+Ro7MeKYS54P93+QN9mbxVVZqQsOSOuxict7nXH47cBnDmALFkAPYbDBKlVTYduWr6m6eIl032EObXQ4MUU=@vger.kernel.org X-Gm-Message-State: AOJu0YyvSAmNo7k6NPAjTipDviOh0i9SYtjHB7FT1mHB5yxEN/k/7+lI Auxwbbz4kL2gAvQOTFdhM4opCoK1LPDikqkyrS54TlYQG2CcdA5VzuU= X-Gm-Gg: AfdE7clWON1h9t4qygbw0r0QeLvm+dJT5UPA7rT+NG9zSNlDaossklPaYXXG4V04F+o +qW/BCzCJz0e+0P3z2wE763mUYrVFRwAI80SLtzM8RC8/TX+shUQpp6JNkFpk87W2v6cWSkTzQK J3CZ8G1wUvcWdnlLje6b1rrwwgXgyMTN36aX7zXCCZ6aixzaWAf5h05rTiYs+udWz7HNrO23tgN QBkOj+r5aERHF1xQdJgG/uzTcdJUZGwU3BhPLrR/UljVvsl4GtcVbp92p1k/kQtO2EWXD+Js+et 7d0wgrjtVtMHto6ZfqKTOW4MW921YBeH1uKbgtD57841YyQBUy/OvPj708rQnK5I6MdgKi44OST xWRCVvvN29uPXKDn4aaGSghxJjiesKP93C61xNHY3xw3UQ9bzZUpifP/A+XB7WOMXPMIP1Jzo4t SgHlIt7hcBek41jVAQQH1Y+8EWEwhNefuZU6TsN8pqRkPyACw+fGc0wwxVEQqMDgdQxwFapWX61 CtWHhGCiLHdJ9QduLuT1vO21reOoBUZ7TqZnocIV53mMEaH5PfWDV3F04Us X-Received: by 2002:a17:902:f70e:b0:2c8:21c4:e14a with SMTP id d9443c01a7336-2c821c4e303mr8737065ad.17.1782466458239; Fri, 26 Jun 2026 02:34:18 -0700 (PDT) Received: from localhost.localdomain ([14.5.152.27]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c7f63b2e18sm36677835ad.41.2026.06.26.02.34.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 26 Jun 2026 02:34:17 -0700 (PDT) From: Myeonghun Pak To: Michael Turquette , Stephen Boyd Cc: Mike Looijmans , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Myeonghun Pak , Ijae Kim Subject: [PATCH] clk: si5341: disable input clock on probe failure and remove Date: Fri, 26 Jun 2026 18:33:07 +0900 Message-ID: <20260626093410.67573-1-mhun512@gmail.com> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit si5341_clk_select_active_input() prepares and enables the selected input clock, but the driver never disables it. The devm-managed clock lookup only releases the clock handle; it does not unwind the prepare/enable count. Track the input clock that was successfully prepared and disable it from both the post-selection probe error path and the remove path. Fixes: 3044a860fd09 ("clk: Add Si5341/Si5340 driver") Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak --- drivers/clk/clk-si5341.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c index 2499b77..14f80a5 100644 --- a/drivers/clk/clk-si5341.c +++ b/drivers/clk/clk-si5341.c @@ -74,6 +74,7 @@ struct clk_si5341 { struct clk_si5341_output clk[SI5341_MAX_NUM_OUTPUTS]; struct clk *input_clk[SI5341_NUM_INPUTS]; const char *input_clk_name[SI5341_NUM_INPUTS]; + int prepared_input; const u16 *reg_output_offset; const u16 *reg_rdiv_offset; u64 freq_vco; /* 13500–14256 MHz */ @@ -1463,9 +1464,20 @@ static int si5341_clk_select_active_input(struct clk_si5341 *data) if (err < 0) return err; + data->prepared_input = res; + return res; } +static void si5341_clk_disable_active_input(struct clk_si5341 *data) +{ + if (data->prepared_input < 0) + return; + + clk_disable_unprepare(data->input_clk[data->prepared_input]); + data->prepared_input = -1; +} + static ssize_t input_present_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -1571,6 +1583,7 @@ static int si5341_probe(struct i2c_client *client) if (!data) return -ENOMEM; + data->prepared_input = -1; data->i2c_client = client; /* Must be done before otherwise touching hardware */ @@ -1803,6 +1816,7 @@ static int si5341_probe(struct i2c_client *client) cleanup: if (err) { + si5341_clk_disable_active_input(data); for (i = 0; i < SI5341_MAX_NUM_OUTPUTS; ++i) { if (data->clk[i].vddo_reg) regulator_disable(data->clk[i].vddo_reg); @@ -1818,6 +1832,8 @@ static void si5341_remove(struct i2c_client *client) sysfs_remove_files(&client->dev.kobj, si5341_attributes); + si5341_clk_disable_active_input(data); + for (i = 0; i < SI5341_MAX_NUM_OUTPUTS; ++i) { if (data->clk[i].vddo_reg) regulator_disable(data->clk[i].vddo_reg); -- 2.50.0