Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit 4f9d406c authored by Li Nan's avatar Li Nan Committed by Richard Weinberger
Browse files

ubi: block: fix null-pointer-dereference in ubiblock_create()

Similar to commit adbf4c49 ("ubi: block: fix memleak in
ubiblock_create()"), 'dev->gd' is not assigned but dereferenced if
blk_mq_alloc_tag_set() fails, and leading to a null-pointer-dereference.
Fix it by using pr_err() and variable 'dev' to print error log.

Additionally, the log in the error handle path of idr_alloc() has
been improved by using pr_err(), too. Before initializing device
name, using dev_err() will print error log with 'null' instead of
the actual device name, like this:
  block (null): ...
        ~~~~~~
It is unclear. Using pr_err() can print more details of the device.
The improved log is:
  ubiblock0_0: ...

Fixes: 77567b25

 ("ubi: use blk_mq_alloc_disk and blk_cleanup_disk")
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
Reviewed-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: default avatarDaniel Golle <daniel@makrotopia.org>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 39986148
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