aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-03-11 09:34:35 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-04-17 06:43:32 -0400
commit7a6f0b22706e2314dbba91f53d20502050aec1d2 (patch)
tree7b4772155fd7483d6a45a0233ebcba753b48617e /drivers
parent2d4e9d1db22117ebcd4f3353cb45292a8704d511 (diff)
[media] media: Properly handle link flags in link setup, link notify callback
The link flags were not properly handled in __media_entity_setup_link which could lead to link_notify callback to be called when the flags are not modified. Fix this. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/media-entity.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 23640ed44d85..056138f63c7d 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -378,7 +378,6 @@ EXPORT_SYMBOL_GPL(media_entity_create_link);
378 378
379static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) 379static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
380{ 380{
381 const u32 mask = MEDIA_LNK_FL_ENABLED;
382 int ret; 381 int ret;
383 382
384 /* Notify both entities. */ 383 /* Notify both entities. */
@@ -395,7 +394,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
395 return ret; 394 return ret;
396 } 395 }
397 396
398 link->flags = (link->flags & ~mask) | (flags & mask); 397 link->flags = flags;
399 link->reverse->flags = link->flags; 398 link->reverse->flags = link->flags;
400 399
401 return 0; 400 return 0;
@@ -417,6 +416,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
417 */ 416 */
418int __media_entity_setup_link(struct media_link *link, u32 flags) 417int __media_entity_setup_link(struct media_link *link, u32 flags)
419{ 418{
419 const u32 mask = MEDIA_LNK_FL_ENABLED;
420 struct media_device *mdev; 420 struct media_device *mdev;
421 struct media_entity *source, *sink; 421 struct media_entity *source, *sink;
422 int ret = -EBUSY; 422 int ret = -EBUSY;
@@ -424,6 +424,10 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)
424 if (link == NULL) 424 if (link == NULL)
425 return -EINVAL; 425 return -EINVAL;
426 426
427 /* The non-modifiable link flags must not be modified. */
428 if ((link->flags & ~mask) != (flags & ~mask))
429 return -EINVAL;
430
427 if (link->flags & MEDIA_LNK_FL_IMMUTABLE) 431 if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
428 return link->flags == flags ? 0 : -EINVAL; 432 return link->flags == flags ? 0 : -EINVAL;
429 433