@@ -266,23 +266,28 @@ void iscsi_destroy_endpoint(struct iscsi_endpoint *ep)
266266}
267267EXPORT_SYMBOL_GPL (iscsi_destroy_endpoint );
268268
269+ void iscsi_put_endpoint (struct iscsi_endpoint * ep )
270+ {
271+ put_device (& ep -> dev );
272+ }
273+ EXPORT_SYMBOL_GPL (iscsi_put_endpoint );
274+
275+ /**
276+ * iscsi_lookup_endpoint - get ep from handle
277+ * @handle: endpoint handle
278+ *
279+ * Caller must do a iscsi_put_endpoint.
280+ */
269281struct iscsi_endpoint * iscsi_lookup_endpoint (u64 handle )
270282{
271- struct iscsi_endpoint * ep ;
272283 struct device * dev ;
273284
274285 dev = class_find_device (& iscsi_endpoint_class , NULL , & handle ,
275286 iscsi_match_epid );
276287 if (!dev )
277288 return NULL ;
278289
279- ep = iscsi_dev_to_endpoint (dev );
280- /*
281- * we can drop this now because the interface will prevent
282- * removals and lookups from racing.
283- */
284- put_device (dev );
285- return ep ;
290+ return iscsi_dev_to_endpoint (dev );
286291}
287292EXPORT_SYMBOL_GPL (iscsi_lookup_endpoint );
288293
@@ -2990,6 +2995,7 @@ static int iscsi_if_ep_disconnect(struct iscsi_transport *transport,
29902995 }
29912996
29922997 transport -> ep_disconnect (ep );
2998+ iscsi_put_endpoint (ep );
29932999 return 0 ;
29943000}
29953001
@@ -3015,6 +3021,7 @@ iscsi_if_transport_ep(struct iscsi_transport *transport,
30153021
30163022 ev -> r .retcode = transport -> ep_poll (ep ,
30173023 ev -> u .ep_poll .timeout_ms );
3024+ iscsi_put_endpoint (ep );
30183025 break ;
30193026 case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT :
30203027 rc = iscsi_if_ep_disconnect (transport ,
@@ -3698,6 +3705,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
36983705 ev -> u .c_bound_session .initial_cmdsn ,
36993706 ev -> u .c_bound_session .cmds_max ,
37003707 ev -> u .c_bound_session .queue_depth );
3708+ iscsi_put_endpoint (ep );
37013709 break ;
37023710 case ISCSI_UEVENT_DESTROY_SESSION :
37033711 session = iscsi_session_lookup (ev -> u .d_session .sid );
@@ -3769,6 +3777,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
37693777 mutex_lock (& conn -> ep_mutex );
37703778 conn -> ep = ep ;
37713779 mutex_unlock (& conn -> ep_mutex );
3780+ iscsi_put_endpoint (ep );
37723781 } else
37733782 iscsi_cls_conn_printk (KERN_ERR , conn ,
37743783 "Could not set ep conn "
0 commit comments