bluetooth: unregister correct BTPROTO for CMTP
Subsystems (3)
PATCH 1/1 bluetooth: unregister correct BTPROTO for CMTP
On error unregister BTPROTO_CMTP to match the registration earlier in the same code-path. Without this change BTPROTO_HIDP is incorrectly unregistered.
This bug does not appear to cause serious security problem.
The function 'bt_sock_unregister' takes its parameter as an index and NULLs the corresponding element of 'bt_proto' which is an array of pointers. When 'bt_proto' dereferences each element, it would check whether the element is empty or not. Therefore, the problem of null pointer deference does not occur.
Found by inspection.
Fixes 8c8de589cedd ("Bluetooth: Added /proc/net/cmtp via bt_procfs_init()")
Signed-off-by Chenyuan Mi <[email protected]>
--- net/bluetooth/cmtp/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/cmtp/sock.c +1 -1
@@ -250,7 +250,7 @@ int cmtp_init_sockets(void) err =bt_procfs_init (&init_net,"cmtp" , &cmtp_sk_list,NULL );if (err <0 ) {BT_ERR ("Failed to create CMTP proc file" ); -bt_sock_unregister (BTPROTO_HIDP ); +bt_sock_unregister (BTPROTO_CMTP ); goto error; }
Signature · 1 line
2.25.1