All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Scally <djrscally@gmail.com>
To: linux-media@vger.kernel.org
Cc: sakari.ailus@linux.intel.com, andriy.shevchenko@linux.intel.com,
	laurent.pinchart@ideasonboard.com, yong.zhi@intel.com,
	bingbu.cao@intel.com, tian.shu.qiu@intel.com,
	jeanmichel.hautbois@ideasonboard.com,
	kieran.bingham@ideasonboard.com, hdegoede@redhat.com
Subject: [PATCH v5 5/5] media: i2c: ov5693: Fix lockdep error
Date: Mon,  1 Nov 2021 23:21:44 +0000	[thread overview]
Message-ID: <20211101232144.134590-6-djrscally@gmail.com> (raw)
In-Reply-To: <20211101232144.134590-1-djrscally@gmail.com>

From: Hans de Goede <hdegoede@redhat.com>

ov5693_s_stream() was calling __v4l2_ctrl_handler_setup() without first
locking ov5693->lock, triggering the "lockdep_assert_held(hdl->lock);"
check in __v4l2_ctrl_handler_setup() leading to a kernel backtrace.

ov5693_s_stream() does already take the ov5693->lock, move the
mutex_lock call up (in the enable path) so that it also protects the
__v4l2_ctrl_handler_setup() call.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/media/i2c/ov5693.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c
index 2613bad49f78..e3cd7eeba9ed 100644
--- a/drivers/media/i2c/ov5693.c
+++ b/drivers/media/i2c/ov5693.c
@@ -1113,17 +1113,23 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable)
 		if (ret < 0)
 			goto err_power_down;
 
+		mutex_lock(&ov5693->lock);
 		ret = __v4l2_ctrl_handler_setup(&ov5693->ctrls.handler);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&ov5693->lock);
 			goto err_power_down;
-	}
-
-	mutex_lock(&ov5693->lock);
-	ret = ov5693_enable_streaming(ov5693, enable);
-	mutex_unlock(&ov5693->lock);
+		}
 
+		ret = ov5693_enable_streaming(ov5693, true);
+		mutex_unlock(&ov5693->lock);
+	} else {
+		mutex_lock(&ov5693->lock);
+		ret = ov5693_enable_streaming(ov5693, false);
+		mutex_unlock(&ov5693->lock);
+	}
 	if (ret)
 		goto err_power_down;
+
 	ov5693->streaming = !!enable;
 
 	if (!enable)
-- 
2.25.1


      parent reply	other threads:[~2021-11-01 23:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 23:21 [PATCH v5 0/5] Add support for OV5693 sensor Daniel Scally
2021-11-01 23:21 ` [PATCH v5 1/5] media: ipu3-cio2: Toggle sensor streaming in pm runtime ops Daniel Scally
2021-11-01 23:21 ` [PATCH v5 2/5] media: i2c: Add support for ov5693 sensor Daniel Scally
2021-11-02  9:15   ` Hans de Goede
2021-11-02  9:49   ` Sakari Ailus
2021-11-01 23:21 ` [PATCH v5 3/5] media: ipu3-cio2: Add link freq for INT33BE entry Daniel Scally
2021-11-01 23:21 ` [PATCH v5 4/5] media: i2c: ov5693: Rename ov5693_sw_standby() to ov5693_enable_streaming() Daniel Scally
2021-11-02  9:24   ` Hans de Goede
2021-11-02  9:29     ` Daniel Scally
2021-11-01 23:21 ` Daniel Scally [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211101232144.134590-6-djrscally@gmail.com \
    --to=djrscally@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bingbu.cao@intel.com \
    --cc=hdegoede@redhat.com \
    --cc=jeanmichel.hautbois@ideasonboard.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tian.shu.qiu@intel.com \
    --cc=yong.zhi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.