Skip to contentSkip to conversation

drivers/of/of_net.c:64:2-8: ERROR: missing put_device; call of_find_device_by_node on line 57, but without a corresponding object release within this function. (fwd)

DISCUSSION Julia Lawall 1 participant 1 message May 12, 2019

lore
Share & tools
lore
#0 lore raw

Hello,

You should drop the reference count on the value allocated with of_find_device_by_node on line 57.

julia

---------- Forwarded message ----------
Date: Sun, 12 May 2019 10:20:42 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: drivers/of/of_net.c:64:2-8: ERROR: missing put_device; call
of_find_device_by_node on line 57,
but without a corresponding object release within this function.

CC: [email protected]
CC: [email protected]
TO: "Petr Štetiar" <[email protected]>
CC: Felix Fietkau <[email protected]>
CC: John Crispin <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   8148c17b179d8acad190551fe0fb90d8f5193990
commit: d01f449c008a3f41fa44c603e28a7452ab8f8e68 of_net: add NVMEM support to of_get_mac_address
date:   6 days ago

:::::: branch date: 11 hours ago
:::::: commit date: 6 days ago

If you fix the issue, kindly add following tag

Quoted 1 line
Quoted 1 line

drivers/of/of_net.c:64:2-8: ERROR: missing put_device; call of_find_device_by_node on line 57, but without a corresponding object release within this function.

drivers/of/of_net.c:68:2-8: ERROR: missing put_device; call of_find_device_by_node on line 57, but without a corresponding object release within this function. drivers/of/of_net.c:82:1-7: ERROR: missing put_device; call of_find_device_by_node on line 57, but without a corresponding object release within this function. drivers/of/of_net.c:87:1-7: ERROR: missing put_device; call of_find_device_by_node on line 57, but without a corresponding object release within this function.

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d01f449c008a3f41fa44c603e28a7452ab8f8e68
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout d01f449c008a3f41fa44c603e28a7452ab8f8e68
vim +64 drivers/of/of_net.c

3eb46a1da Sergei Shtylyov 2015-03-18 51

d01f449c0 Petr Štetiar    2019-05-03  52  static const void *of_get_mac_addr_nvmem(struct device_node *np)
d01f449c0 Petr Štetiar    2019-05-03  53  {
d01f449c0 Petr Štetiar    2019-05-03  54  	int ret;
d01f449c0 Petr Štetiar    2019-05-03  55  	u8 mac[ETH_ALEN];
d01f449c0 Petr Štetiar    2019-05-03  56  	struct property *pp;
d01f449c0 Petr Štetiar    2019-05-03 @57  	struct platform_device *pdev = of_find_device_by_node(np);
d01f449c0 Petr Štetiar    2019-05-03  58
d01f449c0 Petr Štetiar    2019-05-03  59  	if (!pdev)
d01f449c0 Petr Štetiar    2019-05-03  60  		return ERR_PTR(-ENODEV);
d01f449c0 Petr Štetiar    2019-05-03  61
d01f449c0 Petr Štetiar    2019-05-03  62  	ret = nvmem_get_mac_address(&pdev->dev, &mac);
d01f449c0 Petr Štetiar    2019-05-03  63  	if (ret)
d01f449c0 Petr Štetiar    2019-05-03 @64  		return ERR_PTR(ret);
d01f449c0 Petr Štetiar    2019-05-03  65
d01f449c0 Petr Štetiar    2019-05-03  66  	pp = devm_kzalloc(&pdev->dev, sizeof(*pp), GFP_KERNEL);
d01f449c0 Petr Štetiar    2019-05-03  67  	if (!pp)
d01f449c0 Petr Štetiar    2019-05-03  68  		return ERR_PTR(-ENOMEM);
d01f449c0 Petr Štetiar    2019-05-03  69
d01f449c0 Petr Štetiar    2019-05-03  70  	pp->name = "nvmem-mac-address";
d01f449c0 Petr Štetiar    2019-05-03  71  	pp->length = ETH_ALEN;
d01f449c0 Petr Štetiar    2019-05-03  72  	pp->value = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL);
d01f449c0 Petr Štetiar    2019-05-03  73  	if (!pp->value) {
d01f449c0 Petr Štetiar    2019-05-03  74  		ret = -ENOMEM;
d01f449c0 Petr Štetiar    2019-05-03  75  		goto free;
d01f449c0 Petr Štetiar    2019-05-03  76  	}
d01f449c0 Petr Štetiar    2019-05-03  77
d01f449c0 Petr Štetiar    2019-05-03  78  	ret = of_add_property(np, pp);
d01f449c0 Petr Štetiar    2019-05-03  79  	if (ret)
d01f449c0 Petr Štetiar    2019-05-03  80  		goto free;
d01f449c0 Petr Štetiar    2019-05-03  81
d01f449c0 Petr Štetiar    2019-05-03  82  	return pp->value;
d01f449c0 Petr Štetiar    2019-05-03  83  free:
d01f449c0 Petr Štetiar    2019-05-03  84  	devm_kfree(&pdev->dev, pp->value);
d01f449c0 Petr Štetiar    2019-05-03  85  	devm_kfree(&pdev->dev, pp);
d01f449c0 Petr Štetiar    2019-05-03  86
d01f449c0 Petr Štetiar    2019-05-03  87  	return ERR_PTR(ret);
d01f449c0 Petr Štetiar    2019-05-03  88  }
d01f449c0 Petr Štetiar    2019-05-03  89

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation