From: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
To: martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
linux-kernel@vger.kernel.org,
Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Subject: [PATCH] target: Fix a double put in transport_free_session
Date: Mon, 22 Mar 2021 19:58:51 -0700 [thread overview]
Message-ID: <20210323025851.11782-1-lyl2019@mail.ustc.edu.cn> (raw)
In transport_free_session, se_nacl is got from se_sess
with the initial reference. If se_nacl->acl_sess_list is
empty, se_nacl->dynamic_stop is set to true. Then the first
target_put_nacl(se_nacl) will drop the initial reference
and free se_nacl. Later there is a second target_put_nacl()
to put se_nacl. It may cause error in race.
My patch sets se_nacl->dynamic_stop to false to avoid the
double put.
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
---
drivers/target/target_core_transport.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 5ecb9f18a53d..c266defe694f 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -584,8 +584,10 @@ void transport_free_session(struct se_session *se_sess)
}
mutex_unlock(&se_tpg->acl_node_mutex);
- if (se_nacl->dynamic_stop)
+ if (se_nacl->dynamic_stop) {
target_put_nacl(se_nacl);
+ se_nacl->dynamic_stop = false;
+ }
target_put_nacl(se_nacl);
}
--
2.25.1
next reply other threads:[~2021-03-23 2:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-23 2:58 Lv Yunlong [this message]
2021-03-23 16:28 ` [PATCH] target: Fix a double put in transport_free_session michael.christie
2021-03-25 7:48 ` lyl2019
2021-03-25 17:24 ` Mike Christie
2021-03-26 11:11 ` lyl2019
2021-03-26 12:31 ` Maurizio Lombardi
2021-03-26 16:24 ` Mike Christie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210323025851.11782-1-lyl2019@mail.ustc.edu.cn \
--to=lyl2019@mail.ustc.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).