diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index 97287d4b6..848da81a5 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1566,6 +1566,14 @@ static struct device scst_local_root = { static struct device *scst_local_root; #endif +static void scst_local_free_sess(struct scst_session *scst_sess) +{ + struct scst_local_sess *sess = scst_sess_get_tgt_priv(scst_sess); + + kfree(sess); + return; +} + static void scst_local_release_adapter(struct device *dev) { struct scst_local_sess *sess; @@ -1591,9 +1599,7 @@ static void scst_local_release_adapter(struct device *dev) cancel_work_sync(&sess->aen_work); #endif - scst_unregister_session(sess->scst_sess, true, NULL); - - kfree(sess); + scst_unregister_session(sess->scst_sess, false, scst_local_free_sess); out: TRACE_EXIT();