mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-02 14:34:13 -04:00
net: ucc_geth: use devm for kmemdup
Avoids manual frees for it. Funny enough the free in _remove should be the last thing done. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://patch.msgid.link/20241104210127.307420-2-rosenp@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
fda960354e
commit
2246f5b2e9
@@ -3591,22 +3591,23 @@ static int ucc_geth_probe(struct platform_device* ofdev)
|
||||
if ((ucc_num < 0) || (ucc_num > 7))
|
||||
return -ENODEV;
|
||||
|
||||
ug_info = kmemdup(&ugeth_primary_info, sizeof(*ug_info), GFP_KERNEL);
|
||||
if (ug_info == NULL)
|
||||
ug_info = devm_kmemdup(&ofdev->dev, &ugeth_primary_info,
|
||||
sizeof(*ug_info), GFP_KERNEL);
|
||||
if (!ug_info)
|
||||
return -ENOMEM;
|
||||
|
||||
ug_info->uf_info.ucc_num = ucc_num;
|
||||
|
||||
err = ucc_geth_parse_clock(np, "rx", &ug_info->uf_info.rx_clock);
|
||||
if (err)
|
||||
goto err_free_info;
|
||||
return err;
|
||||
err = ucc_geth_parse_clock(np, "tx", &ug_info->uf_info.tx_clock);
|
||||
if (err)
|
||||
goto err_free_info;
|
||||
return err;
|
||||
|
||||
err = of_address_to_resource(np, 0, &res);
|
||||
if (err)
|
||||
goto err_free_info;
|
||||
return err;
|
||||
|
||||
ug_info->uf_info.regs = res.start;
|
||||
ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
|
||||
@@ -3619,7 +3620,7 @@ static int ucc_geth_probe(struct platform_device* ofdev)
|
||||
*/
|
||||
err = of_phy_register_fixed_link(np);
|
||||
if (err)
|
||||
goto err_free_info;
|
||||
return err;
|
||||
ug_info->phy_node = of_node_get(np);
|
||||
}
|
||||
|
||||
@@ -3748,9 +3749,6 @@ static int ucc_geth_probe(struct platform_device* ofdev)
|
||||
of_phy_deregister_fixed_link(np);
|
||||
of_node_put(ug_info->tbi_node);
|
||||
of_node_put(ug_info->phy_node);
|
||||
err_free_info:
|
||||
kfree(ug_info);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -3766,7 +3764,6 @@ static void ucc_geth_remove(struct platform_device* ofdev)
|
||||
of_phy_deregister_fixed_link(np);
|
||||
of_node_put(ugeth->ug_info->tbi_node);
|
||||
of_node_put(ugeth->ug_info->phy_node);
|
||||
kfree(ugeth->ug_info);
|
||||
free_netdev(dev);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user