Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] fix: net: marvell: orion_mdio_probe: fix clock reference leak on extra   clock detection
From: WenTao Liang @ 2026-06-28  4:02 UTC (permalink / raw)
  To: Andrew Lunn, netdev
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	stable, linux-kernel
In-Reply-To: <20260626151926.51342-1-vulab@iscas.ac.cn>



> 2026年6月26日 23:19,WenTao Liang <vulab@iscas.ac.cn> 写道:
> 
> The code calls of_clk_get(pdev->dev.of_node, ARRAY_SIZE(dev->clk)) to
>  detect unsupported extra clocks. If an extra clock exists, the function
>  prints a warning but discards the returned clk pointer without calling
>  clk_put, leaking a clock reference on every probe.
> 
> Store the returned clock and call clk_put after the warning to properly
>  release the acquired reference.
> 
> Cc: stable@vger.kernel.org
> Fixes: ea664b1bdc19 ("net: mvmdio: print warning when orion-mdio has too many clocks")
> Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
> ---
> drivers/net/ethernet/marvell/mvmdio.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index 3f4447e68888..4e5b5c5f7301 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -339,11 +339,18 @@ static int orion_mdio_probe(struct platform_device *pdev)
> 			clk_prepare_enable(dev->clk[i]);
> 		}
> 
> -		if (!IS_ERR(of_clk_get(pdev->dev.of_node,
> -				       ARRAY_SIZE(dev->clk))))
> -			dev_warn(&pdev->dev,
> -				 "unsupported number of clocks, limiting to the first "
> -				 __stringify(ARRAY_SIZE(dev->clk)) "\n");
> +		{
> +			struct clk *extra_clk;
> +
> +			extra_clk = of_clk_get(pdev->dev.of_node,
> +					       ARRAY_SIZE(dev->clk));
> +			if (!IS_ERR(extra_clk)) {
> +				dev_warn(&pdev->dev,
> +					 "unsupported number of clocks, limiting to the first "
> +					 __stringify(ARRAY_SIZE(dev->clk)) "\n");
> +				clk_put(extra_clk);
> +			}
> +		}
> 
> 		if (type == BUS_TYPE_XSMI)
> 			orion_mdio_xsmi_set_mdc_freq(bus);
> -- 
> 2.39.5 (Apple Git-154)

Please ignore this patch. I will resend a proper version after
learning the kernel submission process.

Apologies for the noise.

Best regards,
WenTao Liang


^ permalink raw reply

* [PATCH v2] ptp: ocp: add I2C ISP support for ADVA TimeCard CPLD
From: Sagi Maimon @ 2026-06-28  5:38 UTC (permalink / raw)
  To: jonathan.lemon, vadim.fedorenko, richardcochran, andrew+netdev,
	davem, edumazet, kuba, pabeni
  Cc: linux-kernel, netdev, Sagi Maimon

The ADVA TimeCard programs its on-board CPLD (Lattice MachXO3)
via I2C using in-system programming (ISP).

The CPLD resides on a secondary I2C bus controlled by the
embedded MicroBlaze. To allow programming, the driver must
take ownership of this bus and expose it to userspace.

Add support to:
  - enable the i2c-dev interface to expose /dev/i2c-N
  - provide sysfs control over the secondary I2C bus

Signed-off-by: Sagi Maimon <maimon.sagi@gmail.com>
---
 Address comments from:
  - Andrew Lunn: https://www.spinics.net/lists/netdev/msg1200997.html

 Changes since v1:
  - Add reasoning to the commit message
 
 
 drivers/ptp/ptp_ocp.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 35e911f1ad78..1b4ccb4feca5 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -4224,6 +4224,34 @@ static const struct ocp_attr_group art_timecard_groups[] = {
 	{ },
 };
 
+static ssize_t
+i2c_bus_ctrl_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct ptp_ocp *bp = dev_get_drvdata(dev);
+
+	if (!bp->pps_select)
+		return -ENODEV;
+	return sysfs_emit(buf, "0x%08x\n",
+			  ioread32(&bp->pps_select->__pad1));
+}
+
+static ssize_t
+i2c_bus_ctrl_store(struct device *dev, struct device_attribute *attr,
+		   const char *buf, size_t count)
+{
+	struct ptp_ocp *bp = dev_get_drvdata(dev);
+	u32 val;
+
+	if (!bp->pps_select)
+		return -ENODEV;
+	if (kstrtou32(buf, 0, &val))
+		return -EINVAL;
+	iowrite32(val, &bp->pps_select->__pad1);
+	return count;
+}
+
+static DEVICE_ATTR_RW(i2c_bus_ctrl);
+
 static struct attribute *adva_timecard_attrs[] = {
 	&dev_attr_serialnum.attr,
 	&dev_attr_gnss_sync.attr,
@@ -4272,6 +4300,7 @@ static struct attribute *adva_timecard_x1_attrs[] = {
 	&dev_attr_ts_window_adjust.attr,
 	&dev_attr_utc_tai_offset.attr,
 	&dev_attr_tod_correction.attr,
+	&dev_attr_i2c_bus_ctrl.attr,
 	NULL,
 };
 
@@ -5235,6 +5264,7 @@ ptp_ocp_init(void)
 	const char *what;
 	int err;
 
+	request_module("i2c-dev");
 	ptp_ocp_debugfs_init();
 
 	what = "timecard class";
-- 
2.47.0


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox