Yuan Can
7485edb2b6
media: i2c: ov772x: Fix memleak in ov772x_probe()
A memory leak was reported when testing ov772x with bpf mock device:
AssertionError: unreferenced object 0xffff888109afa7a8 (size 8):
comm "python3", pid 279, jiffies 4294805921 (age 20.681s)
hex dump (first 8 bytes):
80 22 88 15 81 88 ff ff ."......
backtrace:
[<000000009990b438>] __kmalloc_node+0x44/0x1b0
[<000000009e32f7d7>] kvmalloc_node+0x34/0x180
[<00000000faf48134>] v4l2_ctrl_handler_init_class+0x11d/0x180 [videodev]
[<00000000da376937>] ov772x_probe+0x1c3/0x68c [ov772x]
[<000000003f0d225e>] i2c_device_probe+0x28d/0x680
[<00000000e0b6db89>] really_probe+0x17c/0x3f0
[<000000001b19fcee>] __driver_probe_device+0xe3/0x170
[<0000000048370519>] driver_probe_device+0x49/0x120
[<000000005ead07a0>] __device_attach_driver+0xf7/0x150
[<0000000043f452b8>] bus_for_each_drv+0x114/0x180
[<00000000358e5596>] __device_attach+0x1e5/0x2d0
[<0000000043f83c5d>] bus_probe_device+0x126/0x140
[<00000000ee0f3046>] device_add+0x810/0x1130
[<00000000e0278184>] i2c_new_client_device+0x359/0x4f0
[<0000000070baf34f>] of_i2c_register_device+0xf1/0x110
[<00000000a9f2159d>] of_i2c_notify+0x100/0x160
unreferenced object 0xffff888119825c00 (size 256):
comm "python3", pid 279, jiffies 4294805921 (age 20.681s)
hex dump (first 32 bytes):
00 b4 a5 17 81 88 ff ff 00 5e 82 19 81 88 ff ff .........^......
10 5c 82 19 81 88 ff ff 10 5c 82 19 81 88 ff ff .\.......\......
backtrace:
[<000000009990b438>] __kmalloc_node+0x44/0x1b0
[<000000009e32f7d7>] kvmalloc_node+0x34/0x180
[<0000000073d88e0b>] v4l2_ctrl_new.cold+0x19b/0x86f [videodev]
[<00000000b1f576fb>] v4l2_ctrl_new_std+0x16f/0x210 [videodev]
[<00000000caf7ac99>] ov772x_probe+0x1fa/0x68c [ov772x]
[<000000003f0d225e>] i2c_device_probe+0x28d/0x680
[<00000000e0b6db89>] really_probe+0x17c/0x3f0
[<000000001b19fcee>] __driver_probe_device+0xe3/0x170
[<0000000048370519>] driver_probe_device+0x49/0x120
[<000000005ead07a0>] __device_attach_driver+0xf7/0x150
[<0000000043f452b8>] bus_for_each_drv+0x114/0x180
[<00000000358e5596>] __device_attach+0x1e5/0x2d0
[<0000000043f83c5d>] bus_probe_device+0x126/0x140
[<00000000ee0f3046>] device_add+0x810/0x1130
[<00000000e0278184>] i2c_new_client_device+0x359/0x4f0
[<0000000070baf34f>] of_i2c_register_device+0xf1/0x110
The reason is that if priv->hdl.error is set, ov772x_probe() jumps to the
error_mutex_destroy without doing v4l2_ctrl_handler_free(), and all
resources allocated in v4l2_ctrl_handler_init() and v4l2_ctrl_new_std()
are leaked.
Fixes: 1112babde2 ("media: i2c: Copy ov772x soc_camera sensor driver")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2023-02-06 08:39:04 +01:00
..
2022-12-16 13:04:15 -06:00
2022-12-25 13:38:09 -08:00
2022-12-13 15:22:14 -08:00
2022-12-13 10:54:19 -08:00
2022-12-25 13:38:09 -08:00
2022-12-19 12:33:32 -06:00
2022-12-25 13:38:09 -08:00
2022-12-25 13:38:09 -08:00
2022-12-16 03:49:24 -08:00
2022-12-20 03:13:45 +01:00
2022-12-13 13:46:07 -08:00
2022-12-12 12:52:02 -08:00
2022-12-12 16:39:38 -08:00
2022-12-19 07:13:33 -06:00
2022-12-19 07:13:33 -06:00
2022-12-08 13:03:47 -08:00
2022-12-19 08:54:17 -06:00
2022-12-16 03:54:54 -08:00
2022-12-12 15:40:03 +01:00
2022-12-16 03:49:24 -08:00
2022-12-21 09:37:14 -08:00
2022-12-16 03:49:24 -08:00
2022-12-21 09:41:28 -08:00
2022-12-25 13:38:09 -08:00
2022-12-25 13:38:09 -08:00
2022-12-13 15:47:48 -08:00
2022-12-13 13:09:38 -08:00
2022-12-15 14:47:10 -08:00
2022-12-11 21:25:58 +01:00
2022-12-16 03:49:24 -08:00
2022-12-17 08:23:42 -06:00
2022-12-25 13:38:09 -08:00
2022-12-19 08:34:39 -06:00
2022-12-14 15:23:49 -08:00
2022-12-25 13:38:09 -08:00
2022-12-25 13:38:09 -08:00
2022-12-21 09:31:18 -08:00
2022-12-13 10:58:09 -08:00
2023-02-06 08:39:04 +01:00
2022-12-13 15:22:14 -08:00
2022-12-09 10:29:58 +01:00
2022-12-21 09:19:24 -08:00
2022-12-23 12:00:24 -08:00
2022-12-13 13:41:26 -08:00
2022-12-13 12:32:07 -08:00
2022-12-25 13:38:09 -08:00
2022-12-25 13:38:09 -08:00
2022-12-22 11:22:31 -08:00
2022-12-16 03:49:24 -08:00
2022-12-20 08:48:24 -06:00
2022-12-17 23:19:38 +01:00
2022-12-19 08:40:58 -06:00
2022-12-25 13:38:09 -08:00
2022-12-14 15:23:49 -08:00
2022-12-19 08:40:58 -06:00
2022-12-13 13:03:06 -08:00
2022-12-16 03:22:53 -08:00
2022-12-17 08:39:31 -06:00
2022-12-13 15:47:48 -08:00
2022-12-21 09:41:28 -08:00
2022-12-11 19:30:20 -08:00
2022-12-23 14:38:00 -08:00
2022-12-07 11:20:55 -07:00
2022-12-21 09:19:24 -08:00
2022-12-16 03:54:54 -08:00
2022-12-25 13:38:09 -08:00
2022-12-19 16:07:59 -06:00
2022-12-19 08:47:33 -06:00
2022-12-23 14:44:08 -08:00
2023-02-06 08:34:51 +01:00
2022-12-14 08:58:51 -08:00
2022-12-12 10:17:08 -08:00
2022-12-15 10:16:04 -08:00
2022-12-25 13:38:09 -08:00
2022-12-14 08:58:51 -08:00
2022-12-25 13:38:09 -08:00
2022-12-16 03:54:54 -08:00
2022-12-21 09:24:39 -08:00
2022-12-16 03:49:24 -08:00
2022-12-17 08:34:01 -06:00
2022-12-13 11:59:58 -08:00