Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: hci_sock: Reset cookie to zero in hci_sock_free_cookie()

Reset cookie value to 0 instead of 0xffffffff in hci_sock_free_cookie()
since:
0 : means cookie has not been assigned yet
0xffffffff: means cookie assignment failure

Also fix generating cookie failure with usage shown below:
hci_sock_gen_cookie(sk) // generate cookie
hci_sock_free_cookie(sk) // free cookie
hci_sock_gen_cookie(sk) // Can't generate cookie any more

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Zijun Hu and committed by
Luiz Augusto von Dentz
4d7936e8 b47c97f2

+1 -1
+1 -1
net/bluetooth/hci_sock.c
··· 118 118 int id = hci_pi(sk)->cookie; 119 119 120 120 if (id) { 121 - hci_pi(sk)->cookie = 0xffffffff; 121 + hci_pi(sk)->cookie = 0; 122 122 ida_free(&sock_cookie_ida, id); 123 123 } 124 124 }