summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-07-31 15:05:37 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-08-01 08:38:57 +0200
commit15fe5e42b2bff3544434e07aff98262507ab04b3 (patch)
tree4b5f244a3e2448092169b02cb630a7f1942edf12
parentb8fa109b252797e458f35ab7f5525a8a2332a6d5 (diff)
downloadbarebox-15fe5e42b2bff3544434e07aff98262507ab04b3.tar.gz
of_partition: devfs_add_partition returns an error pointer
Check for the return value of devfs_add_partition with IS_ERR. Otherwise we dereference a NULL pointer when devfs_add_partition fails. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/of/partition.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index 5ed44a8..c3a404c 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -21,6 +21,7 @@
#include <of.h>
#include <malloc.h>
#include <linux/mtd/mtd.h>
+#include <linux/err.h>
#include <nand.h>
struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
@@ -60,10 +61,14 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
filename = asprintf("%s.%s", cdev->name, partname);
new = devfs_add_partition(cdev->name, offset, size, flags, filename);
+ if (IS_ERR(new)) {
+ new = NULL;
+ goto out;
+ }
if (cdev->mtd && cdev->mtd->type == MTD_NANDFLASH)
dev_add_bb_dev(filename, NULL);
-
+out:
free(filename);
return new;