aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/core.c
diff options
context:
space:
mode:
authorRakesh Pandit <rakesh@tuxera.com>2017-10-13 08:45:52 -0400
committerJens Axboe <axboe@kernel.dk>2017-10-13 10:34:57 -0400
commit88d31ea2676696ad0802a361c8b824f0762fa34c (patch)
tree21493fab751ba4bbe1c06571f3948cc8358ec04d /drivers/lightnvm/core.c
parentbb6aa6f08268bbce4e0185b18cab9e04505d6695 (diff)
lightnvm: protect target type list with correct locks
nvm_tgt_types list was protected by wrong lock for NVM_INFO ioctl call and can race with addition or removal of target types. Also unregistering target type was not protected correctly. Fixes: 5cd907853 ("lightnvm: remove nested lock conflict with mm") Signed-off-by: Rakesh Pandit <rakesh@tuxera.com> Reviewed-by: Javier González <javier@cnexlabs.com> Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/core.c')
-rw-r--r--drivers/lightnvm/core.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index c490711cf0f4..ee2b6d771990 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -589,9 +589,9 @@ void nvm_unregister_tgt_type(struct nvm_tgt_type *tt)
589 if (!tt) 589 if (!tt)
590 return; 590 return;
591 591
592 down_write(&nvm_lock); 592 down_write(&nvm_tgtt_lock);
593 list_del(&tt->list); 593 list_del(&tt->list);
594 up_write(&nvm_lock); 594 up_write(&nvm_tgtt_lock);
595} 595}
596EXPORT_SYMBOL(nvm_unregister_tgt_type); 596EXPORT_SYMBOL(nvm_unregister_tgt_type);
597 597
@@ -1195,7 +1195,7 @@ static long nvm_ioctl_info(struct file *file, void __user *arg)
1195 info->version[1] = NVM_VERSION_MINOR; 1195 info->version[1] = NVM_VERSION_MINOR;
1196 info->version[2] = NVM_VERSION_PATCH; 1196 info->version[2] = NVM_VERSION_PATCH;
1197 1197
1198 down_write(&nvm_lock); 1198 down_write(&nvm_tgtt_lock);
1199 list_for_each_entry(tt, &nvm_tgt_types, list) { 1199 list_for_each_entry(tt, &nvm_tgt_types, list) {
1200 struct nvm_ioctl_info_tgt *tgt = &info->tgts[tgt_iter]; 1200 struct nvm_ioctl_info_tgt *tgt = &info->tgts[tgt_iter];
1201 1201
@@ -1208,7 +1208,7 @@ static long nvm_ioctl_info(struct file *file, void __user *arg)
1208 } 1208 }
1209 1209
1210 info->tgtsize = tgt_iter; 1210 info->tgtsize = tgt_iter;
1211 up_write(&nvm_lock); 1211 up_write(&nvm_tgtt_lock);
1212 1212
1213 if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info))) { 1213 if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info))) {
1214 kfree(info); 1214 kfree(info);