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]
Message-Id: <1548146084-20445-1-git-send-email-xinwu.liu@intel.com>
Date:   Tue, 22 Jan 2019 16:34:44 +0800
From:   "Liu, Xinwu" <xinwu.liu@...el.com>
To:     mchehab@...nel.org
Cc:     hans.verkuil@...co.com, sakari.ailus@...ux.intel.com,
        niklas.soderlund+renesas@...natech.se, ezequiel@...labora.com,
        sque@...omium.org, linux-media@...r.kernel.org,
        linux-kernel@...r.kernel.org, xinwu.liu@...el.com
Subject: [PATCH] media: v4l2-core: expose the device after it was registered.

device_register exposes the device to userspace.

Therefore, while the register process is ongoing, the userspace program
will fail to open the device (ENODEV will be set to errno currently).
The program in userspace must re-open the device to cover this case.

It is more reasonable to expose the device after everythings ready.

Signed-off-by: Liu, Xinwu <xinwu.liu@...el.com>
---
 drivers/media/v4l2-core/v4l2-dev.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index d7528f8..01e5cc9 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -993,16 +993,11 @@ int __video_register_device(struct video_device *vdev,
 		goto cleanup;
 	}
 
-	/* Part 4: register the device with sysfs */
+	/* Part 4: Prepare to register the device */
 	vdev->dev.class = &video_class;
 	vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor);
 	vdev->dev.parent = vdev->dev_parent;
 	dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
-	ret = device_register(&vdev->dev);
-	if (ret < 0) {
-		pr_err("%s: device_register failed\n", __func__);
-		goto cleanup;
-	}
 	/* Register the release callback that will be called when the last
 	   reference to the device goes away. */
 	vdev->dev.release = v4l2_device_release;
@@ -1020,6 +1015,13 @@ int __video_register_device(struct video_device *vdev,
 	/* Part 6: Activate this minor. The char device can now be used. */
 	set_bit(V4L2_FL_REGISTERED, &vdev->flags);
 
+	/* Part 7: Register the device with sysfs */
+	ret = device_register(&vdev->dev);
+	if (ret < 0) {
+		pr_err("%s: device_register failed\n", __func__);
+		goto cleanup;
+	}
+
 	return 0;
 
 cleanup:
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ