Commit fde201a4 authored by Hua Su's avatar Hua Su Committed by Jens Axboe

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: default avatarHua Su <suhua.tanke@gmail.com>
Reviewed-by: default avatarJavier González <javier@cnexlabs.com>
Signed-off-by: default avatarMatias Bjørling <mb@lightnvm.io>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6e82f0ba
...@@ -1295,15 +1295,22 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line) ...@@ -1295,15 +1295,22 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line)
ret = pblk_line_alloc_bitmaps(pblk, line); ret = pblk_line_alloc_bitmaps(pblk, line);
if (ret) if (ret)
return ret; goto fail;
if (!pblk_line_init_bb(pblk, line, 0)) { if (!pblk_line_init_bb(pblk, line, 0)) {
list_add(&line->list, &l_mg->free_list); ret = -EINTR;
return -EINTR; goto fail;
} }
pblk_rl_free_lines_dec(&pblk->rl, line, true); pblk_rl_free_lines_dec(&pblk->rl, line, true);
return 0; 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) void pblk_line_recov_close(struct pblk *pblk, struct pblk_line *line)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment