@@ -195,7 +195,7 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info,
195
195
196
196
adm_ctx .minor = d_in -> minor ;
197
197
adm_ctx .mdev = minor_to_mdev (d_in -> minor );
198
- adm_ctx .tconn = conn_by_name (adm_ctx .conn_name );
198
+ adm_ctx .tconn = conn_get_by_name (adm_ctx .conn_name );
199
199
200
200
if (!adm_ctx .mdev && (flags & DRBD_ADM_NEED_MINOR )) {
201
201
drbd_msg_put_info ("unknown minor" );
@@ -223,8 +223,7 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info,
223
223
drbd_msg_put_info ("minor exists as different volume" );
224
224
return ERR_INVALID_REQUEST ;
225
225
}
226
- if (adm_ctx .mdev && !adm_ctx .tconn )
227
- adm_ctx .tconn = adm_ctx .mdev -> tconn ;
226
+
228
227
return NO_ERROR ;
229
228
230
229
fail :
@@ -238,6 +237,11 @@ static int drbd_adm_finish(struct genl_info *info, int retcode)
238
237
struct nlattr * nla ;
239
238
const char * conn_name = NULL ;
240
239
240
+ if (adm_ctx .tconn ) {
241
+ kref_put (& adm_ctx .tconn -> kref , & conn_destroy );
242
+ adm_ctx .tconn = NULL ;
243
+ }
244
+
241
245
if (!adm_ctx .reply_skb )
242
246
return - ENOMEM ;
243
247
@@ -2748,10 +2752,13 @@ int drbd_adm_get_status_all(struct sk_buff *skb, struct netlink_callback *cb)
2748
2752
if (!nla )
2749
2753
return - EINVAL ;
2750
2754
conn_name = nla_data (nla );
2751
- tconn = conn_by_name (conn_name );
2755
+ tconn = conn_get_by_name (conn_name );
2756
+
2752
2757
if (!tconn )
2753
2758
return - ENODEV ;
2754
2759
2760
+ kref_put (& tconn -> kref , & conn_destroy ); /* get_one_status() (re)validates tconn by itself */
2761
+
2755
2762
/* prime iterators, and set "filter" mode mark:
2756
2763
* only dump this tconn. */
2757
2764
cb -> args [0 ] = (long )tconn ;
0 commit comments