]> 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>
Wed, 5 Oct 2011 13:49:00 +0000 (15:49 +0200)
commit39d7f636df2e18add5dc06898bcd2187f7ec7c16
treed651da82696acc010907c428607862104f76a519
parent7fc19c5579c1d683c3236fce8c0bfe3f501f2030
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