Skip to content

Commit

Permalink
media: mc-entity.c: use WARN_ON, validate link pads
Browse files Browse the repository at this point in the history
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 <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: use ! instead of == NULL for source and sink]
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Feb 24, 2020
1 parent 0c9d29e commit a3fbc2e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/media/mc/mc-entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,14 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
struct media_link *link;
struct media_link *backlink;

BUG_ON(source == NULL || sink == NULL);
BUG_ON(source_pad >= source->num_pads);
BUG_ON(sink_pad >= sink->num_pads);
if (WARN_ON(!source || !sink) ||
WARN_ON(source_pad >= source->num_pads) ||
WARN_ON(sink_pad >= sink->num_pads))
return -EINVAL;
if (WARN_ON(!(source->pads[source_pad].flags & MEDIA_PAD_FL_SOURCE)))
return -EINVAL;
if (WARN_ON(!(sink->pads[sink_pad].flags & MEDIA_PAD_FL_SINK)))
return -EINVAL;

link = media_add_link(&source->links);
if (link == NULL)
Expand Down

0 comments on commit a3fbc2e

Please sign in to comment.