[PATCH] mtd: ubi: avoid NULL pointer dereference in ubi_get_device
Philipp Zabel
p.zabel at pengutronix.de
Wed Mar 19 09:25:02 EDT 2014
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 at pengutronix.de>
---
drivers/mtd/ubi/build.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index da21f69..b908fcd 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -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++;
--
1.9.0
More information about the barebox
mailing list