Commit 26574986 authored by Petr Štetiar's avatar Petr Štetiar Committed by David S. Miller

of_net: remove nvmem-mac-address property

In commit d01f449c ("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: d01f449c ("of_net: add NVMEM support to of_get_mac_address")
Suggested-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarPetr Štetiar <ynezz@true.cz>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0655f994
...@@ -52,39 +52,22 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name) ...@@ -52,39 +52,22 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name)
static const void *of_get_mac_addr_nvmem(struct device_node *np) static const void *of_get_mac_addr_nvmem(struct device_node *np)
{ {
int ret; int ret;
u8 mac[ETH_ALEN]; const void *mac;
struct property *pp; u8 nvmem_mac[ETH_ALEN];
struct platform_device *pdev = of_find_device_by_node(np); struct platform_device *pdev = of_find_device_by_node(np);
if (!pdev) if (!pdev)
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
ret = nvmem_get_mac_address(&pdev->dev, &mac); ret = nvmem_get_mac_address(&pdev->dev, &nvmem_mac);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
pp = devm_kzalloc(&pdev->dev, sizeof(*pp), GFP_KERNEL); mac = devm_kmemdup(&pdev->dev, nvmem_mac, ETH_ALEN, GFP_KERNEL);
if (!pp) if (!mac)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
pp->name = "nvmem-mac-address"; return mac;
pp->length = ETH_ALEN;
pp->value = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL);
if (!pp->value) {
ret = -ENOMEM;
goto free;
}
ret = of_add_property(np, pp);
if (ret)
goto free;
return pp->value;
free:
devm_kfree(&pdev->dev, pp->value);
devm_kfree(&pdev->dev, pp);
return ERR_PTR(ret);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment