aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2019-05-10 05:35:14 -0400
committerDavid S. Miller <davem@davemloft.net>2019-05-10 18:14:29 -0400
commit265749861a2483263e6cd4c5e305640e4651c110 (patch)
treed41a2384d12abe186f6a382461e5ed831184edfa /drivers/of
parent0655f9943df2f2d71f406fd77b51d05548134fc2 (diff)
of_net: remove nvmem-mac-address property
In commit d01f449c008a ("of_net: add NVMEM support to of_get_mac_address") I've added `nvmem-mac-address` property which was wrong idea as I've allocated the property with devm_kzalloc and then added it to DT, so then 2 entities would be refcounting the allocation. So if the driver unbinds, the buffer is freed, but DT code would be still referencing that memory. I'm removing this property completely instead of fixing it, as it's not needed to have it. Fixes: d01f449c008a ("of_net: add NVMEM support to of_get_mac_address") Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: Petr Štetiar <ynezz@true.cz> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/of_net.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index 9649cd53e955..a4b392a5406b 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -52,39 +52,22 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name)
52static const void *of_get_mac_addr_nvmem(struct device_node *np) 52static const void *of_get_mac_addr_nvmem(struct device_node *np)
53{ 53{
54 int ret; 54 int ret;
55 u8 mac[ETH_ALEN]; 55 const void *mac;
56 struct property *pp; 56 u8 nvmem_mac[ETH_ALEN];
57 struct platform_device *pdev = of_find_device_by_node(np); 57 struct platform_device *pdev = of_find_device_by_node(np);
58 58
59 if (!pdev) 59 if (!pdev)
60 return ERR_PTR(-ENODEV); 60 return ERR_PTR(-ENODEV);
61 61
62 ret = nvmem_get_mac_address(&pdev->dev, &mac); 62 ret = nvmem_get_mac_address(&pdev->dev, &nvmem_mac);
63 if (ret) 63 if (ret)
64 return ERR_PTR(ret); 64 return ERR_PTR(ret);
65 65
66 pp = devm_kzalloc(&pdev->dev, sizeof(*pp), GFP_KERNEL); 66 mac = devm_kmemdup(&pdev->dev, nvmem_mac, ETH_ALEN, GFP_KERNEL);
67 if (!pp) 67 if (!mac)
68 return ERR_PTR(-ENOMEM); 68 return ERR_PTR(-ENOMEM);
69 69
70 pp->name = "nvmem-mac-address"; 70 return mac;
71 pp->length = ETH_ALEN;
72 pp->value = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL);
73 if (!pp->value) {
74 ret = -ENOMEM;
75 goto free;
76 }
77
78 ret = of_add_property(np, pp);
79 if (ret)
80 goto free;
81
82 return pp->value;
83free:
84 devm_kfree(&pdev->dev, pp->value);
85 devm_kfree(&pdev->dev, pp);
86
87 return ERR_PTR(ret);
88} 71}
89 72
90/** 73/**