media: rcar-csi2: Cleanup mutex on remove and fail
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Wed, 15 Sep 2021 01:50:12 +0000 (03:50 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 5 Oct 2021 07:36:26 +0000 (09:36 +0200)
The mutex was not destroyed on remove or failed probe, fix this.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/rcar-vin/rcar-csi2.c

index d7f560e312d4451ac7e128826edf0321bcd50191..0967ae3bed7ecef9e63a3b4944c60bae9792e72e 100644 (file)
@@ -1421,14 +1421,14 @@ static int rcsi2_probe(struct platform_device *pdev)
        ret = rcsi2_probe_resources(priv, pdev);
        if (ret) {
                dev_err(priv->dev, "Failed to get resources\n");
-               return ret;
+               goto error_mutex;
        }
 
        platform_set_drvdata(pdev, priv);
 
        ret = rcsi2_parse_dt(priv);
        if (ret)
-               return ret;
+               goto error_mutex;
 
        priv->subdev.owner = THIS_MODULE;
        priv->subdev.dev = &pdev->dev;
@@ -1450,21 +1450,23 @@ static int rcsi2_probe(struct platform_device *pdev)
        ret = media_entity_pads_init(&priv->subdev.entity, num_pads,
                                     priv->pads);
        if (ret)
-               goto error;
+               goto error_async;
 
        pm_runtime_enable(&pdev->dev);
 
        ret = v4l2_async_register_subdev(&priv->subdev);
        if (ret < 0)
-               goto error;
+               goto error_async;
 
        dev_info(priv->dev, "%d lanes found\n", priv->lanes);
 
        return 0;
 
-error:
+error_async:
        v4l2_async_nf_unregister(&priv->notifier);
        v4l2_async_nf_cleanup(&priv->notifier);
+error_mutex:
+       mutex_destroy(&priv->lock);
 
        return ret;
 }
@@ -1479,6 +1481,8 @@ static int rcsi2_remove(struct platform_device *pdev)
 
        pm_runtime_disable(&pdev->dev);
 
+       mutex_destroy(&priv->lock);
+
        return 0;
 }