diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 448245423..612946eb6 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5470,6 +5470,8 @@ static int scst_alloc_add_tgt_dev(struct scst_session *sess, *out_tgt_dev = tgt_dev; + percpu_ref_get(&dev->refcnt); + out: TRACE_EXIT_RES(res); return res; @@ -5572,6 +5574,8 @@ static void scst_free_tgt_dev(struct scst_tgt_dev *tgt_dev) kmem_cache_free(scst_tgtd_cachep, tgt_dev); + percpu_ref_put(&dev->refcnt); + TRACE_EXIT(); return; }