9
0
Fork 0

mtd: ubi: avoid NULL pointer dereference in ubi_get_device

If the ubidetach command is given a number that passes the range check
in ubi_detach_mtd_dev, but at which index the ubi_devices array contains
a NULL pointer, ubi_get_device tries to dereference this NULL pointer
to increment the ubi device reference count.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Philipp Zabel 2014-03-19 14:25:02 +01:00 committed by Sascha Hauer
parent d10caffecb
commit 4449fac898
1 changed files with 2 additions and 0 deletions

View File

@ -104,6 +104,8 @@ struct ubi_device *ubi_get_device(int ubi_num)
struct ubi_device *ubi;
ubi = ubi_devices[ubi_num];
if (!ubi)
return NULL;
ubi->ref_count++;