@@ -286,15 +286,13 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
286286 struct qib_ibdev * dev = to_idev (ibqp -> device );
287287 struct qib_ibport * ibp = to_iport (ibqp -> device , qp -> port_num );
288288 struct qib_mcast * mcast = NULL ;
289- struct qib_mcast_qp * p , * tmp ;
289+ struct qib_mcast_qp * p , * tmp , * delp = NULL ;
290290 struct rb_node * n ;
291291 int last = 0 ;
292292 int ret ;
293293
294- if (ibqp -> qp_num <= 1 || qp -> state == IB_QPS_RESET ) {
295- ret = - EINVAL ;
296- goto bail ;
297- }
294+ if (ibqp -> qp_num <= 1 || qp -> state == IB_QPS_RESET )
295+ return - EINVAL ;
298296
299297 spin_lock_irq (& ibp -> lock );
300298
@@ -303,8 +301,7 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
303301 while (1 ) {
304302 if (n == NULL ) {
305303 spin_unlock_irq (& ibp -> lock );
306- ret = - EINVAL ;
307- goto bail ;
304+ return - EINVAL ;
308305 }
309306
310307 mcast = rb_entry (n , struct qib_mcast , rb_node );
@@ -328,6 +325,7 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
328325 */
329326 list_del_rcu (& p -> list );
330327 mcast -> n_attached -- ;
328+ delp = p ;
331329
332330 /* If this was the last attached QP, remove the GID too. */
333331 if (list_empty (& mcast -> qp_list )) {
@@ -338,15 +336,16 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
338336 }
339337
340338 spin_unlock_irq (& ibp -> lock );
339+ /* QP not attached */
340+ if (!delp )
341+ return - EINVAL ;
342+ /*
343+ * Wait for any list walkers to finish before freeing the
344+ * list element.
345+ */
346+ wait_event (mcast -> wait , atomic_read (& mcast -> refcount ) <= 1 );
347+ qib_mcast_qp_free (delp );
341348
342- if (p ) {
343- /*
344- * Wait for any list walkers to finish before freeing the
345- * list element.
346- */
347- wait_event (mcast -> wait , atomic_read (& mcast -> refcount ) <= 1 );
348- qib_mcast_qp_free (p );
349- }
350349 if (last ) {
351350 atomic_dec (& mcast -> refcount );
352351 wait_event (mcast -> wait , !atomic_read (& mcast -> refcount ));
@@ -355,11 +354,7 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
355354 dev -> n_mcast_grps_allocated -- ;
356355 spin_unlock_irq (& dev -> n_mcast_grps_lock );
357356 }
358-
359- ret = 0 ;
360-
361- bail :
362- return ret ;
357+ return 0 ;
363358}
364359
365360int qib_mcast_tree_empty (struct qib_ibport * ibp )
0 commit comments