diff options
author | Hua Su <suhua.tanke@gmail.com> | 2018-12-11 22:16:18 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-12-11 22:22:34 +0300 |
commit | fde201a466c6ad5efd72cb54fdf2cefa8b6c6ad7 (patch) | |
tree | 94420f2360f69a9286473fafde212b50e82c606f /drivers/lightnvm | |
parent | 6e82f0ba00b0addeec27b3a95eb41e6223fc8c4f (diff) | |
download | linux-fde201a466c6ad5efd72cb54fdf2cefa8b6c6ad7.tar.xz |
lightnvm: pblk: add lock protection to list operations
Protect the list_add on the pblk_line_init_bb() error
path in case this code is used for some other purpose
in the future.
Signed-off-by: Hua Su <suhua.tanke@gmail.com>
Reviewed-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm')
-rw-r--r-- | drivers/lightnvm/pblk-core.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 6581c35f51ee..44c5dc046912 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1295,15 +1295,22 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line) ret = pblk_line_alloc_bitmaps(pblk, line); if (ret) - return ret; + goto fail; if (!pblk_line_init_bb(pblk, line, 0)) { - list_add(&line->list, &l_mg->free_list); - return -EINTR; + ret = -EINTR; + goto fail; } pblk_rl_free_lines_dec(&pblk->rl, line, true); return 0; + +fail: + spin_lock(&l_mg->free_lock); + list_add(&line->list, &l_mg->free_list); + spin_unlock(&l_mg->free_lock); + + return ret; } void pblk_line_recov_close(struct pblk *pblk, struct pblk_line *line) |