[PATCH v2 3/8] bootstrap_read_devfs(): Check for errors from devfs_add_partition()
Andrey Smirnov
andrew.smirnov at gmail.com
Sun May 3 14:55:23 PDT 2015
Check for errors returned by devfs_add_partition() and bail if there
are any.
Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
---
Changes since v1:
- Fix a compile time error that snuck in during the time the diff was
being split into multiple patches
lib/bootstrap/devfs.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/bootstrap/devfs.c b/lib/bootstrap/devfs.c
index 82c7d21..ff0540f 100644
--- a/lib/bootstrap/devfs.c
+++ b/lib/bootstrap/devfs.c
@@ -82,10 +82,17 @@ void* bootstrap_read_devfs(char *devname, bool use_bb, int offset,
int ret;
int size = 0;
void *to, *header;
- struct cdev *cdev;
+ struct cdev *cdev, *partition;
char *partname = "x";
- devfs_add_partition(devname, offset, max_size, DEVFS_PARTITION_FIXED, partname);
+ partition = devfs_add_partition(devname, offset, max_size,
+ DEVFS_PARTITION_FIXED, partname);
+ if (IS_ERR_OR_NULL(partition)) {
+ bootstrap_err("%s: failed to add partition (%ld)\n",
+ devname, PTR_ERR(partition));
+ return NULL;
+ }
+
if (use_bb) {
dev_add_bb_dev(partname, "bbx");
partname = "bbx";
--
2.1.4
More information about the barebox
mailing list