]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
pinctrl: fix pinctrl_register error handling
authorAxel Lin <axel.lin@gmail.com>
Fri, 30 Sep 2011 13:08:34 +0000 (21:08 +0800)
committerLinus Walleij <linus.walleij@stericsson.com>
Mon, 10 Oct 2011 12:26:41 +0000 (14:26 +0200)
commit06b080e3d8b849213b827b23f84eb90c21426b02
tree728ffa3f4b2b73ca45bb0e67a4c81b1af97acbe3
parent1be694973c459f6d6a0c35bc2ed09be0592f75d3
pinctrl: fix pinctrl_register error handling

If device_register fails, current code kfree pctldev
multiple times. current code calls "put_device(&pctldev->dev);
kfree(pctldev);" before and after goto out_err.

The correct fix should be:
If device_register fails, we just need to call
put_device(&pctldev->dev); Since we have "release" callback
in pinctrl_type, we don't need to call kfree(pctldev) after
put_device().

If pinctrl_register_pins fails, we need to delete the
successfully registerd device from system by calling
device_del().

In pinctrl_unregister(), calling
device_unregister(&pctldev->dev) will free pctldev (by the
release callback).

We should not call kfree(pctldev) after device_unregister().

Signed-off-by: Axel Lin <axel.lin@gmail.com>
[Rebased to v9 patchset]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/core.c