Skip to content

Commit

Permalink
v4l: xilinx: multi-scaler: Fix warnings for unchecked return value
Browse files Browse the repository at this point in the history
This patch fixes the coverity warnings about return value not being
checked and improper use of negative value.

The actual warnings are:

For xm2msc_parse_of():
Event check_return: Calling of_property_count_strings without
checking return value
Event unchecked_value: Using value hw_vid_fmt_cnt as a function
argument without checking appropriately

Event negative_return_fn: Function of_property_count_strings
(node, "xlnx,vid-formats") returns a negative number
Event negative_returns: hw_vid_fmt_cnt is passed to a parameter
that cannot be negative

Signed-off-by: Akhil Raghu Menon <akhil.raghu.menon@xilinx.com>
Reviewed-by: Vishal Sagar <vishal.sagar@amd.com>
  • Loading branch information
Akhil Raghu Menon authored and michalsimek committed May 24, 2022
1 parent 48a0167 commit 6c70405
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/media/platform/xilinx/xilinx-multi-scaler.c
Expand Up @@ -2286,6 +2286,13 @@ static int xm2msc_parse_of(struct platform_device *pdev,
/* read supported video formats and update internal table */
hw_vid_fmt_cnt = of_property_count_strings(node, "xlnx,vid-formats");

/* Validate the number of strings returned */
if (hw_vid_fmt_cnt < 0)
return hw_vid_fmt_cnt;

if (hw_vid_fmt_cnt > ARRAY_SIZE(formats))
return -EINVAL;

ret = of_property_read_string_array(node, "xlnx,vid-formats",
vid_fmts, hw_vid_fmt_cnt);
if (ret < 0) {
Expand Down

0 comments on commit 6c70405

Please sign in to comment.