aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/video4linux/v4l2-framework.txt
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-04-19 11:27:56 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-04-19 16:23:38 -0400
commitee71e7b3ae1780e4475aa5dd980dd99c0309079b (patch)
tree4c15e0fc2f11ebd5fe5dee23575b87f7394566ed /Documentation/video4linux/v4l2-framework.txt
parentaa6d5f29534a6d1459f9768c591a7a72aadc5941 (diff)
[media] V4L: fix incorrect refcounting
Both radio-keene and dsbr100 did one v4l2_device_get too many. Thus the refcount never became 0 and that causes a memory leak. Also updated the V4L2 framework documentation accordingly. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'Documentation/video4linux/v4l2-framework.txt')
-rw-r--r--Documentation/video4linux/v4l2-framework.txt14
1 files changed, 9 insertions, 5 deletions
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 659b2ba12a4f..e3dfc268d9c1 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -182,11 +182,11 @@ static int __devinit drv_probe(struct pci_dev *pdev,
182} 182}
183 183
184If you have multiple device nodes then it can be difficult to know when it is 184If you have multiple device nodes then it can be difficult to know when it is
185safe to unregister v4l2_device. For this purpose v4l2_device has refcounting 185safe to unregister v4l2_device for hotpluggable devices. For this purpose
186support. The refcount is increased whenever video_register_device is called and 186v4l2_device has refcounting support. The refcount is increased whenever
187it is decreased whenever that device node is released. When the refcount reaches 187video_register_device is called and it is decreased whenever that device node
188zero, then the v4l2_device release() callback is called. You can do your final 188is released. When the refcount reaches zero, then the v4l2_device release()
189cleanup there. 189callback is called. You can do your final cleanup there.
190 190
191If other device nodes (e.g. ALSA) are created, then you can increase and 191If other device nodes (e.g. ALSA) are created, then you can increase and
192decrease the refcount manually as well by calling: 192decrease the refcount manually as well by calling:
@@ -197,6 +197,10 @@ or:
197 197
198int v4l2_device_put(struct v4l2_device *v4l2_dev); 198int v4l2_device_put(struct v4l2_device *v4l2_dev);
199 199
200Since the initial refcount is 1 you also need to call v4l2_device_put in the
201disconnect() callback (for USB devices) or in the remove() callback (for e.g.
202PCI devices), otherwise the refcount will never reach 0.
203
200struct v4l2_subdev 204struct v4l2_subdev
201------------------ 205------------------
202 206