summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-10-17 08:10:23 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-10-17 08:10:23 +0200
commitee6d4a74eb6efa643e7b834b32e04d01c6b29b7f (patch)
tree2ca84274dfe2e54729bca7dc4bbfe42611a1ee7f /common
parentc59d7ab7317014cc14a98c47e91c2b582d5d08a7 (diff)
parent099b135ac30013dfc4b3310a5177cf2f7a17f3c3 (diff)
downloadbarebox-ee6d4a74eb6efa643e7b834b32e04d01c6b29b7f.tar.gz
barebox-ee6d4a74eb6efa643e7b834b32e04d01c6b29b7f.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r--common/blspec.c10
-rw-r--r--common/console.c3
-rw-r--r--common/imd.c20
-rw-r--r--common/partitions/efi.c2
-rw-r--r--common/state/backend_bucket_circular.c4
-rw-r--r--common/state/backend_bucket_direct.c3
-rw-r--r--common/state/state.c7
7 files changed, 30 insertions, 19 deletions
diff --git a/common/blspec.c b/common/blspec.c
index 66e5033e35..83b05993dd 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -229,6 +229,14 @@ static struct blspec_entry *blspec_entry_open(struct bootentries *bootentries,
}
/*
+ * is_blspec_entry - check if a bootentry is a blspec entry
+ */
+static inline bool is_blspec_entry(struct bootentry *entry)
+{
+ return entry->boot == blspec_boot;
+}
+
+/*
* blspec_have_entry - check if we already have an entry with
* a certain path
*/
@@ -238,6 +246,8 @@ static int blspec_have_entry(struct bootentries *bootentries, const char *path)
struct blspec_entry *e;
list_for_each_entry(be, &bootentries->entries, list) {
+ if (!is_blspec_entry(be))
+ continue;
e = container_of(be, struct blspec_entry, entry);
if (e->configpath && !strcmp(e->configpath, path))
return 1;
diff --git a/common/console.c b/common/console.c
index d04aae58f9..e6e029848d 100644
--- a/common/console.c
+++ b/common/console.c
@@ -272,6 +272,9 @@ static int fops_open(struct cdev *cdev, unsigned long flags)
{
struct console_device *priv = cdev->priv;
+ if ((flags & (O_WRONLY | O_RDWR)) && !priv->puts )
+ return -EPERM;
+
return console_open(priv);
}
diff --git a/common/imd.c b/common/imd.c
index 05e118e773..913a01de87 100644
--- a/common/imd.c
+++ b/common/imd.c
@@ -337,8 +337,10 @@ int imd_command(int argc, char *argv[])
return -errno;
imd_start = imd_get(buf, size);
- if (IS_ERR(imd_start))
- return PTR_ERR(imd_start);
+ if (IS_ERR(imd_start)) {
+ ret = PTR_ERR(imd_start);
+ goto out;
+ }
if (type == IMD_TYPE_INVALID) {
imd_for_each(imd_start, imd) {
@@ -356,7 +358,8 @@ int imd_command(int argc, char *argv[])
imd = imd_find_type(imd_start, type);
if (!imd) {
debug("No tag of type 0x%08x found\n", type);
- return -ENODATA;
+ ret = -ENODATA;
+ goto out;
}
if (imd_is_string(type)) {
@@ -370,8 +373,10 @@ int imd_command(int argc, char *argv[])
str = imd_concat_strings(imd);
}
- if (!str)
- return -ENODATA;
+ if (!str) {
+ ret = -ENODATA;
+ goto out;
+ }
if (variable_name)
imd_command_setenv(variable_name, str);
@@ -384,5 +389,8 @@ int imd_command(int argc, char *argv[])
}
}
- return 0;
+ ret = 0;
+out:
+ free(buf);
+ return ret;
}
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 3c1077fd0c..f20fd0d9b9 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -369,7 +369,7 @@ static int find_valid_gpt(void *buf, struct block_device *blk, gpt_header **gpt,
lastlba = last_lba(blk);
if (force_gpt) {
/* This will be added to the EFI Spec. per Intel after v1.02. */
- if (file_detect_type(buf, SECTOR_SIZE * 2) != filetype_gpt)
+ if (file_detect_partition_table(buf, SECTOR_SIZE * 2) != filetype_gpt)
goto fail;
}
diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 47970b79f3..735510e0d3 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -178,10 +178,10 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ
if (ret < 0) {
dev_err(circ->dev, "Failed to read circular storage len %d, %d\n",
len, ret);
- free(buf);
+ return ret;
}
- return ret;
+ return 0;
}
static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *circ,
diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index 0dbd334db8..4522f0170f 100644
--- a/common/state/backend_bucket_direct.c
+++ b/common/state/backend_bucket_direct.c
@@ -115,9 +115,6 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
int ret;
struct state_backend_storage_bucket_direct_meta meta;
- if (len > direct->max_size - sizeof(meta))
- return -E2BIG;
-
if (lseek(direct->fd, direct->offset, SEEK_SET) != direct->offset) {
dev_err(direct->dev, "Failed to seek file, %d\n", -errno);
return -errno;
diff --git a/common/state/state.c b/common/state/state.c
index 3f5d43ecbf..b168387eef 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -714,13 +714,6 @@ struct state *state_by_node(const struct device_node *node)
return NULL;
}
-int state_get_name(const struct state *state, char const **name)
-{
- *name = xstrdup(state->name);
-
- return 0;
-}
-
int state_read_mac(struct state *state, const char *name, u8 *buf)
{
struct state_variable *svar;