51e88cad1efc8d6ea43f9d66ec839ad1fcd55d72
[openwrt/staging/dangole.git] /
1 From 25ab75ec729423e9e230ef3fe027c275ab17addb Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 30 Apr 2020 09:52:50 +0100
4 Subject: [PATCH] media: bcm2835-unicam: Fix reference counting in
5 unicam_open
6
7 The reference counting of node->open was only incremented after
8 a check that the node was v4l2_fh_is_singular_file, which resulted
9 in the counting going wrong and s_power not being called at an
10 appropriate time.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 ---
14 drivers/media/platform/bcm2835/bcm2835-unicam.c | 4 +++-
15 1 file changed, 3 insertions(+), 1 deletion(-)
16
17 --- a/drivers/media/platform/bcm2835/bcm2835-unicam.c
18 +++ b/drivers/media/platform/bcm2835/bcm2835-unicam.c
19 @@ -2170,16 +2170,18 @@ static int unicam_open(struct file *file
20 goto unlock;
21 }
22
23 + node->open++;
24 +
25 if (!v4l2_fh_is_singular_file(file))
26 goto unlock;
27
28 ret = v4l2_subdev_call(dev->sensor, core, s_power, 1);
29 if (ret < 0 && ret != -ENOIOCTLCMD) {
30 v4l2_fh_release(file);
31 + node->open--;
32 goto unlock;
33 }
34
35 - node->open++;
36 ret = 0;
37
38 unlock: