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>