Skip to content

Commit

Permalink
net: pcs: Add missing put_device call in miic_create
Browse files Browse the repository at this point in the history
[ Upstream commit 829c652 ]

The reference of pdev->dev is taken by of_find_device_by_node, so
it should be released when not need anymore.

Fixes: 7dc54d3 ("net: pcs: add Renesas MII converter driver")
Signed-off-by: Xiang Yang <xiangyang3@huawei.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Xiang Yang authored and gregkh committed Aug 23, 2023
1 parent 120a89c commit a41e5a7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/net/pcs/pcs-rzn1-miic.c
Expand Up @@ -317,15 +317,21 @@ struct phylink_pcs *miic_create(struct device *dev, struct device_node *np)

pdev = of_find_device_by_node(pcs_np);
of_node_put(pcs_np);
if (!pdev || !platform_get_drvdata(pdev))
if (!pdev || !platform_get_drvdata(pdev)) {
if (pdev)
put_device(&pdev->dev);
return ERR_PTR(-EPROBE_DEFER);
}

miic_port = kzalloc(sizeof(*miic_port), GFP_KERNEL);
if (!miic_port)
if (!miic_port) {
put_device(&pdev->dev);
return ERR_PTR(-ENOMEM);
}

miic = platform_get_drvdata(pdev);
device_link_add(dev, miic->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
put_device(&pdev->dev);

miic_port->miic = miic;
miic_port->port = port - 1;
Expand Down

0 comments on commit a41e5a7

Please sign in to comment.