of_clk_get() returns a reference that must be released with clk_put() when the clock is no longer needed. The current code never calls clk_put(clk), leaking the reference on both the success path and the clk_rate == 0 error path. Add clk_put(clk) after the clock rate is consumed on the success path, and jump to a new clk_put label on the error path to properly release the clock reference. Signed-off-by: ZhaoJinming --- drivers/net/ethernet/freescale/fman/fman.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fman/fman.c b/drivers/net/ethernet/freescale/fman/fman.c index 013273a2de32..31b0081bdf91 100644 --- a/drivers/net/ethernet/freescale/fman/fman.c +++ b/drivers/net/ethernet/freescale/fman/fman.c @@ -2736,11 +2736,13 @@ static struct fman *read_dts_node(struct platform_device *of_dev) err = -EINVAL; dev_err(&of_dev->dev, "%s: Failed to determine FM%d clock rate\n", __func__, fman->dts_params.id); - goto fman_node_put; + goto clk_put; } /* Rounding to MHz */ fman->dts_params.clk_freq = DIV_ROUND_UP(clk_rate, 1000000); + clk_put(clk); + err = of_property_read_u32_array(fm_node, "fsl,qman-channel-range", &range[0], 2); if (err) { @@ -2818,6 +2820,8 @@ static struct fman *read_dts_node(struct platform_device *of_dev) fman_node_put: of_node_put(fm_node); +clk_put: + clk_put(clk); fman_free: kfree(fman); return ERR_PTR(err); -- 2.20.1