Skip to contentSkip to conversation

decrement struct v4l2_device refcount on device unregister

V4L2 Maciej Szmigiero 1 participant 1 message Aug 29, 2011 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

commit bedf8bcf6b4f90a6e31add3721a2e71877289381 introduced reference counting for struct v4l2_device.

In v4l2_device_register() a call to kref_init() initializes reference count to 1, but in v4l2_device_unregister() there is no corresponding decrement.

End result is that reference count never reaches zero and v4l2_device_release() is never called, not even on videodev module unload.

Fix this by adding reference counter decrement to v4l2_device_unregister().

Resending due to spurious newlines around the patch in previous message.

drivers/media/video/v4l2-device.c +2 -0
index c72856c..eb39af9 100644
@@ -131,6 +131,8 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
 		}
 #endif
 	}
+
+	v4l2_device_put(v4l2_dev);
 }
 EXPORT_SYMBOL_GPL(v4l2_device_unregister);