Skip to content

Commit

Permalink
scst_lib: Fix mem access after free
Browse files Browse the repository at this point in the history
Fixes: #204
  • Loading branch information
lnocturno committed Dec 27, 2023
1 parent 56a6be7 commit aa6cfa1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scst/src/scst_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4505,15 +4505,18 @@ int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent,
scst_cm_on_del_lun(acg_dev, false);

out_free:
/*
* synchronize_rcu() does not have to be called here because the
* tgt_devs that will be freed have never been on any of the
* sess->sess_tgt_dev_list[] lists.
*/
list_for_each_entry_safe(tgt_dev, tt, &tmp_tgt_dev_list,
extra_tgt_dev_list_entry) {
sess = tgt_dev->sess;

mutex_lock(&sess->tgt_dev_list_mutex);
scst_del_tgt_dev(tgt_dev);
mutex_unlock(&sess->tgt_dev_list_mutex);

synchronize_rcu();
scst_free_tgt_dev(tgt_dev);
}

scst_del_free_acg_dev(acg_dev, false);
goto out;
}
Expand Down

0 comments on commit aa6cfa1

Please sign in to comment.