Skip to content

Commit a3fbc2e

Browse files
Hans Verkuilmchehab
authored andcommitted
media: mc-entity.c: use WARN_ON, validate link pads
Use WARN_ON instead of BUG_ON. Add two new WARN_ONs to verify that the source pad is really a source and that the sink pad is really a sink. Signed-off-by: Hans Verkuil <[email protected]> [[email protected]: use ! instead of == NULL for source and sink] Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 0c9d29e commit a3fbc2e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/media/mc/mc-entity.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,14 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
662662
struct media_link *link;
663663
struct media_link *backlink;
664664

665-
BUG_ON(source == NULL || sink == NULL);
666-
BUG_ON(source_pad >= source->num_pads);
667-
BUG_ON(sink_pad >= sink->num_pads);
665+
if (WARN_ON(!source || !sink) ||
666+
WARN_ON(source_pad >= source->num_pads) ||
667+
WARN_ON(sink_pad >= sink->num_pads))
668+
return -EINVAL;
669+
if (WARN_ON(!(source->pads[source_pad].flags & MEDIA_PAD_FL_SOURCE)))
670+
return -EINVAL;
671+
if (WARN_ON(!(sink->pads[sink_pad].flags & MEDIA_PAD_FL_SINK)))
672+
return -EINVAL;
668673

669674
link = media_add_link(&source->links);
670675
if (link == NULL)

0 commit comments

Comments
 (0)