summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/manifest.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2016-01-21 17:34:10 +0100
committerGreg Kroah-Hartman <gregkh@google.com>2016-01-21 22:45:09 -0800
commitd6fba3dbb04dac64cf7fa6d33ea7fce81ecf862c (patch)
tree91e32385c2fdd61f124670ead978bb17f29184a1 /drivers/staging/greybus/manifest.c
parent98fdf5a037f0789f1ea6e22431a4a4cc7c41829d (diff)
downloadlinux-d6fba3dbb04dac64cf7fa6d33ea7fce81ecf862c.tar.bz2
greybus: manifest: check for duplicate CPort descriptors when parsing
Now that connection creation has been separated from interface initialisation, we should explicitly check for duplicate CPort descriptors when parsing the manifest. Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/manifest.c')
-rw-r--r--drivers/staging/greybus/manifest.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c
index 64c60c2dfaf5..5ca36c9001be 100644
--- a/drivers/staging/greybus/manifest.c
+++ b/drivers/staging/greybus/manifest.c
@@ -230,8 +230,7 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
{
struct gb_interface *intf = bundle->intf;
struct greybus_descriptor_cport *desc_cport;
- struct manifest_desc *desc;
- struct manifest_desc *next;
+ struct manifest_desc *desc, *next, *tmp;
LIST_HEAD(list);
u8 bundle_id = bundle->id;
u16 cport_id;
@@ -251,7 +250,19 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
if (cport_id > CPORT_ID_MAX)
goto exit;
- /* Found one, move it to our temporary list. */
+ /*
+ * Found one, move it to our temporary list after checking for
+ * duplicates.
+ */
+ list_for_each_entry(tmp, &list, links) {
+ desc_cport = tmp->data;
+ if (cport_id == desc_cport->id) {
+ dev_err(&bundle->dev,
+ "duplicate CPort %u found\n",
+ cport_id);
+ goto exit;
+ }
+ }
list_move(&desc->links, &list);
count++;
}