From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
"Hans Verkuil" <hans.verkuil@cisco.com>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Sebastian Reichel" <sre@kernel.org>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Paul Kocialkowski" <paul.kocialkowski@bootlin.com>
Subject: [PATCH 2/2] media: v4l2-async: Make subdev notifier cleanup conditional
Date: Wed, 9 Jun 2021 13:54:57 +0200 [thread overview]
Message-ID: <20210609115457.822085-2-paul.kocialkowski@bootlin.com> (raw)
In-Reply-To: <20210609115457.822085-1-paul.kocialkowski@bootlin.com>
A dedicated subdev notified is registered when using the helper
dedicated to sensors (v4l2_async_register_subdev_sensor_common),
but this is not the case when a driver uses v4l2_async_register_subdev
directly.
As a result, add a conditional check to deal with the dedicated subdev
notifier only when necessary at the async subdev unregister step
(and avoid operating on/freeing an unallocated notifier).
Fixes: aef69d54755d ("media: v4l: fwnode: Add a convenience function for registering sensors")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
drivers/media/v4l2-core/v4l2-async.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index cd9e78c63791..e0f4f7551ff3 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -780,10 +780,12 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
mutex_lock(&list_lock);
- __v4l2_async_notifier_unregister(sd->subdev_notifier);
- __v4l2_async_notifier_cleanup(sd->subdev_notifier);
- kfree(sd->subdev_notifier);
- sd->subdev_notifier = NULL;
+ if (sd->subdev_notifier) {
+ __v4l2_async_notifier_unregister(sd->subdev_notifier);
+ __v4l2_async_notifier_cleanup(sd->subdev_notifier);
+ kfree(sd->subdev_notifier);
+ sd->subdev_notifier = NULL;
+ }
if (sd->asd) {
struct v4l2_async_notifier *notifier = sd->notifier;
--
2.31.1
next prev parent reply other threads:[~2021-06-09 11:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 11:54 [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member Paul Kocialkowski
2021-06-09 11:54 ` Paul Kocialkowski [this message]
2021-06-09 12:27 ` [PATCH 2/2] media: v4l2-async: Make subdev notifier cleanup conditional Sakari Ailus
2021-06-09 13:01 ` Paul Kocialkowski
2021-06-09 12:30 ` [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member Sakari Ailus
2021-06-09 13:03 ` Paul Kocialkowski
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=20210609115457.822085-2-paul.kocialkowski@bootlin.com \
--to=paul.kocialkowski@bootlin.com \
--cc=hans.verkuil@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=niklas.soderlund+renesas@ragnatech.se \
--cc=sakari.ailus@linux.intel.com \
--cc=sre@kernel.org \
--cc=thomas.petazzoni@bootlin.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox