]> git.karo-electronics.de Git - karo-tx-linux.git/commit
pinmux: 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, 3 Oct 2011 08:29:21 +0000 (10:29 +0200)
commit2a61b57f2c043e65db40e1161c34d49f4fe3c0f3
tree1c976b6a437db1bba3ee8c93608c01ab3f47e1db
parent5bfe0c9ccc29dd9c9dbe95eba555e656c01d1512
pinmux: 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