summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/bundle.c
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2015-06-09 17:42:57 -0500
committerGreg Kroah-Hartman <gregkh@google.com>2015-06-10 10:38:23 -0700
commit8267616b3ef73b22c9ed5b87905c13fc332fe507 (patch)
tree66e3b74aa5492122ac5d4bcdad355cb9f4be0d01 /drivers/staging/greybus/bundle.c
parentc27a253fc0481b46759082c72d196777ea459a6e (diff)
greybus: bundle: check for duplicate bundle ids
Check at bundle creation time to ensure we're not creating a bundle with an id that's the same as one that's already been created. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/bundle.c')
-rw-r--r--drivers/staging/greybus/bundle.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/staging/greybus/bundle.c b/drivers/staging/greybus/bundle.c
index a6b1b347097a..6e9d03ac7e35 100644
--- a/drivers/staging/greybus/bundle.c
+++ b/drivers/staging/greybus/bundle.c
@@ -165,6 +165,16 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
struct gb_bundle *bundle;
int retval;
+ /*
+ * Reject any attempt to reuse a bundle id. We initialize
+ * these serially, so there's no need to worry about keeping
+ * the interface bundle list locked here.
+ */
+ if (gb_bundle_find(intf, bundle_id)) {
+ pr_err("duplicate bundle id 0x%02hhx\n", bundle_id);
+ return NULL;
+ }
+
bundle = kzalloc(sizeof(*bundle), GFP_KERNEL);
if (!bundle)
return NULL;