Skip to contentSkip to conversation

pinctrl: core: Remove extra kref_get which blocks hogs being freed

PATCH In review Charles Keepax 2 participants 2 messages Feb 28, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: core: Remove extra kref_get which blocks hogs being freed

kref_init starts with the reference count at 1, which will be balanced by the pinctrl_put in pinctrl_unregister. The additional kref_get in pinctrl_claim_hogs will increase this count to 2 and cause the hogs to not get freed when pinctrl_unregister is called.

Fixes 6118714275f0 ("pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()")
---
 drivers/pinctrl/core.c | 1 -
 1 file changed, 1 deletion(-)
drivers/pinctrl/core.c +0 -1
index 446d84fe0e31c..f23c55e221955 100644
@@ -2021,7 +2021,6 @@ static int pinctrl_claim_hogs(struct pinctrl_dev *pctldev)
 		return PTR_ERR(pctldev->p);
 	}
 
-	kref_get(&pctldev->p->users);
 	pctldev->hog_default =
 		pinctrl_lookup_state(pctldev->p, PINCTRL_STATE_DEFAULT);
 	if (IS_ERR(pctldev->hog_default)) {
Signature · 1 line
2.11.0
#1 lore raw
Quoted 7 lines · Charles Keepax

kref_init starts with the reference count at 1, which will be balanced by the pinctrl_put in pinctrl_unregister. The additional kref_get in pinctrl_claim_hogs will increase this count to 2 and cause the hogs to not get freed when pinctrl_unregister is called.

Fixes 6118714275f0 ("pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()")

Patch applied for fixes.

Yours,
Linus Walleij