Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe()

Release some resources in the error handling path of the probe and of
sun8i_a83t_mipi_csi2_resources_setup(), as already done in the remove
function.

Fixes: 576d196c522b ("media: sunxi: Add support for the A83T MIPI CSI-2 controller")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Christophe JAILLET and committed by
Mauro Carvalho Chehab
466c1e6d a90bc000

+18 -5
+18 -5
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
··· 719 719 csi2_dev->clock_mipi = devm_clk_get(dev, "mipi"); 720 720 if (IS_ERR(csi2_dev->clock_mipi)) { 721 721 dev_err(dev, "failed to acquire mipi clock\n"); 722 - return PTR_ERR(csi2_dev->clock_mipi); 722 + ret = PTR_ERR(csi2_dev->clock_mipi); 723 + goto error_clock_rate_exclusive; 723 724 } 724 725 725 726 csi2_dev->clock_misc = devm_clk_get(dev, "misc"); 726 727 if (IS_ERR(csi2_dev->clock_misc)) { 727 728 dev_err(dev, "failed to acquire misc clock\n"); 728 - return PTR_ERR(csi2_dev->clock_misc); 729 + ret = PTR_ERR(csi2_dev->clock_misc); 730 + goto error_clock_rate_exclusive; 729 731 } 730 732 731 733 /* Reset */ ··· 735 733 csi2_dev->reset = devm_reset_control_get_shared(dev, NULL); 736 734 if (IS_ERR(csi2_dev->reset)) { 737 735 dev_err(dev, "failed to get reset controller\n"); 738 - return PTR_ERR(csi2_dev->reset); 736 + ret = PTR_ERR(csi2_dev->reset); 737 + goto error_clock_rate_exclusive; 739 738 } 740 739 741 740 /* D-PHY */ ··· 744 741 ret = sun8i_a83t_dphy_register(csi2_dev); 745 742 if (ret) { 746 743 dev_err(dev, "failed to initialize MIPI D-PHY\n"); 747 - return ret; 744 + goto error_clock_rate_exclusive; 748 745 } 749 746 750 747 /* Runtime PM */ ··· 752 749 pm_runtime_enable(dev); 753 750 754 751 return 0; 752 + 753 + error_clock_rate_exclusive: 754 + clk_rate_exclusive_put(csi2_dev->clock_mod); 755 + 756 + return ret; 755 757 } 756 758 757 759 static void ··· 786 778 787 779 ret = sun8i_a83t_mipi_csi2_bridge_setup(csi2_dev); 788 780 if (ret) 789 - return ret; 781 + goto error_resources; 790 782 791 783 return 0; 784 + 785 + error_resources: 786 + sun8i_a83t_mipi_csi2_resources_cleanup(csi2_dev); 787 + 788 + return ret; 792 789 } 793 790 794 791 static int sun8i_a83t_mipi_csi2_remove(struct platform_device *platform_dev)