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 sun6i_mipi_csi2_probe()

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

Fixes: af54b4f4c17f ("media: sunxi: Add support for the A31 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
51e1440d 466c1e6d

+16 -4
+16 -4
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
··· 661 661 csi2_dev->reset = devm_reset_control_get_shared(dev, NULL); 662 662 if (IS_ERR(csi2_dev->reset)) { 663 663 dev_err(dev, "failed to get reset controller\n"); 664 - return PTR_ERR(csi2_dev->reset); 664 + ret = PTR_ERR(csi2_dev->reset); 665 + goto error_clock_rate_exclusive; 665 666 } 666 667 667 668 /* D-PHY */ ··· 670 669 csi2_dev->dphy = devm_phy_get(dev, "dphy"); 671 670 if (IS_ERR(csi2_dev->dphy)) { 672 671 dev_err(dev, "failed to get MIPI D-PHY\n"); 673 - return PTR_ERR(csi2_dev->dphy); 672 + ret = PTR_ERR(csi2_dev->dphy); 673 + goto error_clock_rate_exclusive; 674 674 } 675 675 676 676 ret = phy_init(csi2_dev->dphy); 677 677 if (ret) { 678 678 dev_err(dev, "failed to initialize MIPI D-PHY\n"); 679 - return ret; 679 + goto error_clock_rate_exclusive; 680 680 } 681 681 682 682 /* Runtime PM */ ··· 685 683 pm_runtime_enable(dev); 686 684 687 685 return 0; 686 + 687 + error_clock_rate_exclusive: 688 + clk_rate_exclusive_put(csi2_dev->clock_mod); 689 + 690 + return ret; 688 691 } 689 692 690 693 static void ··· 719 712 720 713 ret = sun6i_mipi_csi2_bridge_setup(csi2_dev); 721 714 if (ret) 722 - return ret; 715 + goto error_resources; 723 716 724 717 return 0; 718 + 719 + error_resources: 720 + sun6i_mipi_csi2_resources_cleanup(csi2_dev); 721 + 722 + return ret; 725 723 } 726 724 727 725 static int sun6i_mipi_csi2_remove(struct platform_device *platform_dev)