|
@@ -493,12 +493,34 @@ static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
|
|
|
|
|
|
int rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
|
|
|
{
|
|
|
- int r;
|
|
|
+ int r = 0;
|
|
|
+ struct rfcomm_dlc *d_list;
|
|
|
+ struct rfcomm_session *s, *s_list;
|
|
|
+
|
|
|
+ BT_DBG("dlc %p state %ld dlci %d err %d", d, d->state, d->dlci, err);
|
|
|
|
|
|
rfcomm_lock();
|
|
|
|
|
|
- r = __rfcomm_dlc_close(d, err);
|
|
|
+ s = d->session;
|
|
|
+ if (!s)
|
|
|
+ goto no_session;
|
|
|
+
|
|
|
+ /* after waiting on the mutex check the session still exists
|
|
|
+ * then check the dlc still exists
|
|
|
+ */
|
|
|
+ list_for_each_entry(s_list, &session_list, list) {
|
|
|
+ if (s_list == s) {
|
|
|
+ list_for_each_entry(d_list, &s->dlcs, list) {
|
|
|
+ if (d_list == d) {
|
|
|
+ r = __rfcomm_dlc_close(d, err);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+no_session:
|
|
|
rfcomm_unlock();
|
|
|
return r;
|
|
|
}
|