From 9380e29a274fcdbc2bd14fea36bdac35d52c36db Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 10 Mar 2019 04:43:31 +0000 Subject: [PATCH] scst, tgt_dev: Hold a reference on struct scst_device git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8034 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 4 ++++ 1 file changed, 4 insertions(+) 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; }