Skip to content

Commit 829c652

Browse files
Xiang Yangdavem330
authored andcommitted
net: pcs: Add missing put_device call in miic_create
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>
1 parent 51b8131 commit 829c652

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

drivers/net/pcs/pcs-rzn1-miic.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,21 @@ struct phylink_pcs *miic_create(struct device *dev, struct device_node *np)
313313

314314
pdev = of_find_device_by_node(pcs_np);
315315
of_node_put(pcs_np);
316-
if (!pdev || !platform_get_drvdata(pdev))
316+
if (!pdev || !platform_get_drvdata(pdev)) {
317+
if (pdev)
318+
put_device(&pdev->dev);
317319
return ERR_PTR(-EPROBE_DEFER);
320+
}
318321

319322
miic_port = kzalloc(sizeof(*miic_port), GFP_KERNEL);
320-
if (!miic_port)
323+
if (!miic_port) {
324+
put_device(&pdev->dev);
321325
return ERR_PTR(-ENOMEM);
326+
}
322327

323328
miic = platform_get_drvdata(pdev);
324329
device_link_add(dev, miic->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
330+
put_device(&pdev->dev);
325331

326332
miic_port->miic = miic;
327333
miic_port->port = port - 1;

0 commit comments

Comments
 (0)