diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-31 15:05:37 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-01 08:31:47 +0200 |
commit | 79fa5783b87d276e16fae7af0c053a632c5a1381 (patch) | |
tree | b1cb051e1d92b68afb74e0c770ea83dfdd6b6b56 | |
parent | 2fd4f0fbe93ec7e6e10b3475257521dd8418f8e7 (diff) | |
download | barebox-79fa5783b87d276e16fae7af0c053a632c5a1381.tar.gz barebox-79fa5783b87d276e16fae7af0c053a632c5a1381.tar.xz |
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.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/of/partition.c b/drivers/of/partition.c index e2ddec564e..3dce84404f 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,6 +61,9 @@ 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; + if (new && new->dev) new->dev->device_node = node; |