fsl/fman: Fix missing put_device() call in fman_port_probe
authorMiaoqian Lin <linmq006@gmail.com>
Thu, 30 Dec 2021 12:26:27 +0000 (12:26 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Jan 2022 11:33:48 +0000 (12:33 +0100)
[ Upstream commit bf2b09fedc17248b315f80fb249087b7d28a69a6 ]

The reference taken by 'of_find_device_by_node()' must be released when
not needed anymore.
Add the corresponding 'put_device()' in the and error handling paths.

Fixes: 18a6c85fcc78 ("fsl/fman: Add FMan Port Support")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/freescale/fman/fman_port.c

index ac3d791f52821e60d7d63bfa9c9d833981fcd90c..b7295f21aa580aae4a21524f1044bac6c4f083e2 100644 (file)
@@ -1779,7 +1779,7 @@ static int fman_port_probe(struct platform_device *of_dev)
        fman = dev_get_drvdata(&fm_pdev->dev);
        if (!fman) {
                err = -EINVAL;
-               goto return_err;
+               goto put_device;
        }
 
        err = of_property_read_u32(port_node, "cell-index", &val);
@@ -1787,7 +1787,7 @@ static int fman_port_probe(struct platform_device *of_dev)
                dev_err(port->dev, "%s: reading cell-index for %pOF failed\n",
                        __func__, port_node);
                err = -EINVAL;
-               goto return_err;
+               goto put_device;
        }
        port_id = (u8)val;
        port->dts_params.id = port_id;
@@ -1821,7 +1821,7 @@ static int fman_port_probe(struct platform_device *of_dev)
        }  else {
                dev_err(port->dev, "%s: Illegal port type\n", __func__);
                err = -EINVAL;
-               goto return_err;
+               goto put_device;
        }
 
        port->dts_params.type = port_type;
@@ -1835,7 +1835,7 @@ static int fman_port_probe(struct platform_device *of_dev)
                        dev_err(port->dev, "%s: incorrect qman-channel-id\n",
                                __func__);
                        err = -EINVAL;
-                       goto return_err;
+                       goto put_device;
                }
                port->dts_params.qman_channel_id = qman_channel_id;
        }
@@ -1845,7 +1845,7 @@ static int fman_port_probe(struct platform_device *of_dev)
                dev_err(port->dev, "%s: of_address_to_resource() failed\n",
                        __func__);
                err = -ENOMEM;
-               goto return_err;
+               goto put_device;
        }
 
        port->dts_params.fman = fman;
@@ -1870,6 +1870,8 @@ static int fman_port_probe(struct platform_device *of_dev)
 
        return 0;
 
+put_device:
+       put_device(&fm_pdev->dev);
 return_err:
        of_node_put(port_node);
 free_port: