File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
drivers/infiniband/ulp/srpt Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -3104,6 +3104,18 @@ static int srpt_use_srq(struct srpt_device *sdev, bool use_srq)
3104
3104
return ret ;
3105
3105
}
3106
3106
3107
+ static void srpt_free_sdev (struct kref * refcnt )
3108
+ {
3109
+ struct srpt_device * sdev = container_of (refcnt , typeof (* sdev ), refcnt );
3110
+
3111
+ kfree (sdev );
3112
+ }
3113
+
3114
+ static void srpt_sdev_put (struct srpt_device * sdev )
3115
+ {
3116
+ kref_put (& sdev -> refcnt , srpt_free_sdev );
3117
+ }
3118
+
3107
3119
/**
3108
3120
* srpt_add_one - InfiniBand device addition callback function
3109
3121
* @device: Describes a HCA.
@@ -3122,6 +3134,7 @@ static int srpt_add_one(struct ib_device *device)
3122
3134
if (!sdev )
3123
3135
return - ENOMEM ;
3124
3136
3137
+ kref_init (& sdev -> refcnt );
3125
3138
sdev -> device = device ;
3126
3139
mutex_init (& sdev -> sdev_mutex );
3127
3140
@@ -3217,7 +3230,7 @@ static int srpt_add_one(struct ib_device *device)
3217
3230
srpt_free_srq (sdev );
3218
3231
ib_dealloc_pd (sdev -> pd );
3219
3232
free_dev :
3220
- kfree (sdev );
3233
+ srpt_sdev_put (sdev );
3221
3234
pr_info ("%s(%s) failed.\n" , __func__ , dev_name (& device -> dev ));
3222
3235
return ret ;
3223
3236
}
@@ -3261,7 +3274,7 @@ static void srpt_remove_one(struct ib_device *device, void *client_data)
3261
3274
3262
3275
ib_dealloc_pd (sdev -> pd );
3263
3276
3264
- kfree (sdev );
3277
+ srpt_sdev_put (sdev );
3265
3278
}
3266
3279
3267
3280
static struct ib_client srpt_client = {
Original file line number Diff line number Diff line change @@ -434,6 +434,7 @@ struct srpt_port {
434
434
435
435
/**
436
436
* struct srpt_device - information associated by SRPT with a single HCA
437
+ * @refcnt: Reference count for this device.
437
438
* @device: Backpointer to the struct ib_device managed by the IB core.
438
439
* @pd: IB protection domain.
439
440
* @lkey: L_Key (local key) with write access to all local memory.
@@ -449,6 +450,7 @@ struct srpt_port {
449
450
* @port: Information about the ports owned by this HCA.
450
451
*/
451
452
struct srpt_device {
453
+ struct kref refcnt ;
452
454
struct ib_device * device ;
453
455
struct ib_pd * pd ;
454
456
u32 lkey ;
You can’t perform that action at this time.
0 commit comments