diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2014-03-19 14:25:02 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-03-23 09:46:47 +0100 |
commit | 4449fac89875a8fffeaab00edad0e759db81a329 (patch) | |
tree | 959c4377f082bdff2d8315e9f4ba7cad98290e7e /drivers | |
parent | d10caffecb49248d3810def2f2bf73dcba4fd47b (diff) | |
download | barebox-4449fac89875a8fffeaab00edad0e759db81a329.tar.gz barebox-4449fac89875a8fffeaab00edad0e759db81a329.tar.xz |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/ubi/build.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index da21f69e7e..b908fcda0b 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++; |