Commit 2a934fd
media: v4l2-dev: fix error handling in __video_register_device()
Once device_register() failed, we should call put_device() to
decrement reference count for cleanup. Or it could cause memory leak.
And move callback function v4l2_device_release() and v4l2_device_get()
before put_device().
As comment of device_register() says, 'NOTE: _Never_ directly free
@dev after calling this function, even if it returned an error! Always
use put_device() to give up the reference initialized in this function
instead.'
Found by code review.
Cc: stable@vger.kernel.org
Fixes: dc93a70 ("V4L/DVB (9973): v4l2-dev: use the release callback from device instead of cdev")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>1 parent 48dbb76 commit 2a934fd
1 file changed
+7
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1054 | 1054 | | |
1055 | 1055 | | |
1056 | 1056 | | |
| 1057 | + | |
1057 | 1058 | | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1058 | 1063 | | |
1059 | 1064 | | |
1060 | 1065 | | |
1061 | 1066 | | |
1062 | 1067 | | |
1063 | | - | |
| 1068 | + | |
| 1069 | + | |
1064 | 1070 | | |
1065 | | - | |
1066 | | - | |
1067 | | - | |
1068 | 1071 | | |
1069 | 1072 | | |
1070 | 1073 | | |
1071 | 1074 | | |
1072 | 1075 | | |
1073 | | - | |
1074 | | - | |
1075 | | - | |
1076 | 1076 | | |
1077 | 1077 | | |
1078 | 1078 | | |
| |||
0 commit comments