When calling bt_gatt_unsubscribe, the write callback function returns BT_ATT_ERR_UNLIKELY because internally bt_gatt_unsubscribe calls bt_gatt_cancel immediately after gatt_write_ccc.
It seems as though the cancel should go before the gatt_write_ccc in order to cancel a previous write triggered by bt_gatt_subscribe. This was the behavior prior to commit 8d5be19.

Additionally, there is an edge case of bt_gatt_unsubscribe where a notification received between the write request and the write response (CCC) won't get sent to the application because it removes the subscription from sub->list before getting the write response. Since there are server implementations that send out pending notifications prior to sending the write response, it would make more sense if something similar to the following modifications were made:

