Commit 7a6f0b22706e2314dbba91f53d20502050aec1d2

Authored by Laurent Pinchart
Committed by Mauro Carvalho Chehab
1 parent 2d4e9d1db2

[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>

Showing 1 changed file with 6 additions and 2 deletions Side-by-side Diff

drivers/media/media-entity.c
... ... @@ -378,7 +378,6 @@
378 378  
379 379 static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
380 380 {
381   - const u32 mask = MEDIA_LNK_FL_ENABLED;
382 381 int ret;
383 382  
384 383 /* Notify both entities. */
... ... @@ -395,7 +394,7 @@
395 394 return ret;
396 395 }
397 396  
398   - link->flags = (link->flags & ~mask) | (flags & mask);
  397 + link->flags = flags;
399 398 link->reverse->flags = link->flags;
400 399  
401 400 return 0;
402 401  
... ... @@ -417,11 +416,16 @@
417 416 */
418 417 int __media_entity_setup_link(struct media_link *link, u32 flags)
419 418 {
  419 + const u32 mask = MEDIA_LNK_FL_ENABLED;
420 420 struct media_device *mdev;
421 421 struct media_entity *source, *sink;
422 422 int ret = -EBUSY;
423 423  
424 424 if (link == NULL)
  425 + return -EINVAL;
  426 +
  427 + /* The non-modifiable link flags must not be modified. */
  428 + if ((link->flags & ~mask) != (flags & ~mask))
425 429 return -EINVAL;
426 430  
427 431 if (link->flags & MEDIA_LNK_FL_IMMUTABLE)