aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm
diff options
context:
space:
mode:
authortangzhenhao <tzh18@mails.tsinghua.edu.cn>2020-11-29 23:23:56 -0800
committerJens Axboe <axboe@kernel.dk>2020-12-08 10:02:45 -0700
commitf87905660ed01d85e45eac22d479f31f380b2f50 (patch)
treef7921a5f4b1fde5a573a0f91e91b4f2c096bb344 /drivers/lightnvm
parentnull_blk: Move driver into its own directory (diff)
downloadlinux-dev-f87905660ed01d85e45eac22d479f31f380b2f50.tar.xz
linux-dev-f87905660ed01d85e45eac22d479f31f380b2f50.zip
drivers/lightnvm: fix a null-ptr-deref bug in pblk-core.c
At line 294 in drivers/lightnvm/pblk-write.c, function pblk_gen_run_ws is called with actual param GFP_ATOMIC. pblk_gen_run_ws call mempool_alloc using "GFP_ATOMIC" flag, so mempool_alloc can return null. So we need to check the return-val of mempool_alloc to avoid null-ptr-deref bug. Signed-off-by: tangzhenhao <tzh18@mails.tsinghua.edu.cn> Reviewed-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.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 97c68731406b..1dddba11e721 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -1869,6 +1869,10 @@ void pblk_gen_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
struct pblk_line_ws *line_ws;
line_ws = mempool_alloc(&pblk->gen_ws_pool, gfp_mask);
+ if (!line_ws) {
+ pblk_err(pblk, "pblk: could not allocate memory\n");
+ return;
+ }
line_ws->pblk = pblk;
line_ws->line = line;