MLK-20924-1: ISI: fix potential dead lock issue
authorGuoniu.Zhou <guoniu.zhou@nxp.com>
Thu, 14 Feb 2019 02:23:10 +0000 (10:23 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
Fix potential dead lock issue

Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
(cherry picked from commit 322beb5215ea921dd30c0974cd17465de306927b)
(cherry picked from commit aa04582b28aabcd6ec8e5dd5ad0a2310f2111ff0)

drivers/media/platform/imx8/mxc-isi-m2m.c

index 7f59c5f..a629bbc 100644 (file)
@@ -885,6 +885,7 @@ static int mxc_isi_m2m_s_ctrl(struct v4l2_ctrl *ctrl)
 {
        struct mxc_isi_dev *mxc_isi = ctrl_to_mxc_isi_m2m(ctrl);
        unsigned long flags;
+       int ret = 0;
 
        dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__);
 
@@ -895,32 +896,38 @@ static int mxc_isi_m2m_s_ctrl(struct v4l2_ctrl *ctrl)
 
        switch (ctrl->id) {
        case V4L2_CID_HFLIP:
-               if (ctrl->val < 0)
-                       return -EINVAL;
+               if (ctrl->val < 0) {
+                       ret = -EINVAL;
+                       goto unlock;
+               }
                mxc_isi->m2m.hflip = (ctrl->val > 0) ? 1 : 0;
                break;
 
        case V4L2_CID_VFLIP:
-               if (ctrl->val < 0)
-                       return -EINVAL;
+               if (ctrl->val < 0) {
+                       ret = -EINVAL;
+                       goto unlock;
+               }
                mxc_isi->m2m.vflip = (ctrl->val > 0) ? 1 : 0;
                break;
 
        case V4L2_CID_ALPHA_COMPONENT:
-               if (ctrl->val < 0 || ctrl->val > 255)
-                       return -EINVAL;
+               if (ctrl->val < 0 || ctrl->val > 255) {
+                       ret = -EINVAL;
+                       goto unlock;
+               }
                mxc_isi->m2m.alpha = ctrl->val;
                mxc_isi->m2m.alphaen = 1;
                break;
 
        default:
                dev_err(&mxc_isi->pdev->dev, "%s: Not support %d CID\n", __func__, ctrl->id);
-               return -EINVAL;
+               ret = -EINVAL;
        }
 
+unlock:
        spin_unlock_irqrestore(&mxc_isi->slock, flags);
-
-       return 0;
+       return ret;
 }
 
 static const struct v4l2_ctrl_ops mxc_isi_m2m_ctrl_ops = {