lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 16 Jun 2020 19:31:36 +0200
From:   Michael Rodin <mrodin@...adit-jv.com>
To:     Niklas Söderlund <niklas.soderlund@...natech.se>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        <linux-media@...r.kernel.org>, <linux-renesas-soc@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     Michael Rodin <mrodin@...adit-jv.com>, <michael@...in.online>,
        <efriedrich@...adit-jv.com>, <erosca@...adit-jv.com>,
        Steve Longerbeam <steve_longerbeam@...tor.com>
Subject: [PATCH] media: rcar-vin: Move media_device_register to async completion

From: Steve Longerbeam <steve_longerbeam@...tor.com>

The media_device is registered during driver probe, before async
completion, so it is possible for .link_notify to be called before
all devices are bound.

Fix this by moving media_device_register() to rvin_group_notify_complete().
This ensures that all devices are now bound (the rcar-csi2 subdevices and
and video capture devices) before .link_notify can be called.

Signed-off-by: Steve Longerbeam <steve_longerbeam@...tor.com>
Signed-off-by: Michael Rodin <mrodin@...adit-jv.com>
---
 drivers/media/platform/rcar-vin/rcar-core.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 7440c89..e70f83b 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -253,7 +253,6 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin)
 	struct media_device *mdev = &group->mdev;
 	const struct of_device_id *match;
 	struct device_node *np;
-	int ret;
 
 	mutex_init(&group->lock);
 
@@ -266,7 +265,6 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin)
 	vin_dbg(vin, "found %u enabled VIN's in DT", group->count);
 
 	mdev->dev = vin->dev;
-	mdev->ops = &rvin_media_ops;
 
 	match = of_match_node(vin->dev->driver->of_match_table,
 			      vin->dev->of_node);
@@ -278,11 +276,7 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin)
 
 	media_device_init(mdev);
 
-	ret = media_device_register(&group->mdev);
-	if (ret)
-		rvin_group_cleanup(group);
-
-	return ret;
+	return 0;
 }
 
 static void rvin_group_release(struct kref *kref)
@@ -688,6 +682,8 @@ static int rvin_group_notify_complete(struct v4l2_async_notifier *notifier)
 		return ret;
 	}
 
+	vin->group->mdev.ops = &rvin_media_ops;
+
 	/* Register all video nodes for the group. */
 	for (i = 0; i < RCAR_VIN_NUM; i++) {
 		if (vin->group->vin[i] &&
@@ -736,8 +732,10 @@ static int rvin_group_notify_complete(struct v4l2_async_notifier *notifier)
 		}
 	}
 	mutex_unlock(&vin->group->lock);
+	if (ret)
+		return ret;
 
-	return ret;
+	return media_device_register(&vin->group->mdev);
 }
 
 static void rvin_group_notify_unbind(struct v4l2_async_notifier *notifier,
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ