shared: Fix crash if adapter is removed before mgmt event is received

If "Index Removed" mgmt event is received after a mgmt command was sent
by userspace, but before its Command Status/Complete event is received,
bluetoothd will eventually call mgmt_cancel_index(), which will destroy
the queue of pending commands. By the time request_complete() is called,
the request callback is no more valid, because the destroy callback was
already called.

Therefore, the fix is to simply ignore the event.

Valgrind output:

==3676== Invalid read of size 4
==3676==    at 0x80BCD07: request_complete (mgmt.c:239)
==3676==    by 0x80BCF72: can_read_data (mgmt.c:350)
==3676==    by 0x80BBE22: read_callback (io-glib.c:164)
==3676==    by 0x40C019D: g_io_unix_dispatch (giounix.c:166)
==3676==    by 0x407FD45: g_main_context_dispatch (gmain.c:2539)
==3676==    by 0x40800E4: g_main_context_iterate.isra.21 (gmain.c:3146)
==3676==    by 0x408052A: g_main_loop_run (gmain.c:3340)
==3676==    by 0x41BE4D2: (below main) (libc-start.c:226)
==3676==  Address 0x10 is not stack'd, malloc'd or (recently) free'd
tools: Add firmware conversion utility
lib: Add management setting for secure connections
android: Enable secure connections if supported
android: Use LinkKeyPinLength instead of LinkKeyPINLength
android/audio-msg: Simplify audio_rsp_open_stream

Reuse audio_preset in audio_rsp_open_stream since the data type is the
same.
android/bluetooth: Use HAL_STATUS_SUCCESS instead of _DONE in replies

JNI code in Android is mapping returned code to boolean value. Only
SUCCESS status is mapped to true and that value is returned to Java
code. This could result in faultyly triggering error path in Java
when returning DONE in command reply.
android/bluetooth: Rename labels from failed to reply

This name match better and avoid confusion when setting status to
SUCCESS and then jumping to failed label.
android/bluetooth: Log error for any non-success code

Returning non-SUCCESS code in command reply is considered error and
that includes DONE status.
android/tester: Update bluetooth tests with DONE status
attrib: Modify gatt_cb_t signature

Use standard C types instead of GLib ones (which are unnecessary here)
and move the "status" parameter to the first position, so it is
consistent with other callbacks.
attrib: Add missing g_error_free()

Also print error message.
attrib: Use att_put_u16() instead of htobs() + memcpy()
attrib: Remove unnecessary checks for PDU length on ATT encoding

Both userspace and kernel enforce a minimum ATT MTU of 23 octets, which
is also used as minimum size for buffers passed to ATT encoding
functions. Therefore, it is unnecessary to perform these checks on ATT
requests that are guaranteed to fit into 23 octets.

Also document ATT parameter lengths where a constant is being used for
calculating the PDU length.
attrib: Fix PDU length check for Read by Group Type Request

PDU length must be either 7 or 21 octets.
attrib: Add extra PDU checks when decoding Read by Group Type Response

These checks are needed to avoid invalid memory access on bogus PDUs.
attrib: Remove unnecessary NULL checks on dec_find_by_type_req()

Just assume that the caller will pass non-NULL pointers as arguments
(which is true for the only current caller of this function).
attrib: Remove unnecessary local variables from dec_find_by_type_req()

Use number instead of "min_len", which is easier to review (with help of
the documented parameter sizes).

valuelen is redundant as *vlen can be used directly.
attrib: Reject incomplete PDU in dec_find_by_type_resp()

Otherwise, an incomplete PDU may be silently accepted (with any
remaining data discarded).
attrib: Fix PDU length check for Read by Type Request

PDU length must be either 7 or 21 octets.