Commit 1ec4c6ef authored by Aditya Pakki's avatar Aditya Pakki Committed by Mauro Carvalho Chehab

media: saa7146: Avoid using BUG_ON as an assertion

In video_begin and video_end, saa7146_format_by_fourcc can return
NULL and is checked via BUG_ON. However, by returning the error
to the callers upstream, we can avoid the crash and handle it via
recovery code.
Signed-off-by: default avatarAditya Pakki <pakki001@umn.edu>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 93a24578
...@@ -345,7 +345,8 @@ static int video_begin(struct saa7146_fh *fh) ...@@ -345,7 +345,8 @@ static int video_begin(struct saa7146_fh *fh)
fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat);
/* we need to have a valid format set here */ /* we need to have a valid format set here */
BUG_ON(NULL == fmt); if (!fmt)
return -EINVAL;
if (0 != (fmt->flags & FORMAT_IS_PLANAR)) { if (0 != (fmt->flags & FORMAT_IS_PLANAR)) {
resource = RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP|RESOURCE_DMA3_BRS; resource = RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP|RESOURCE_DMA3_BRS;
...@@ -398,7 +399,8 @@ static int video_end(struct saa7146_fh *fh, struct file *file) ...@@ -398,7 +399,8 @@ static int video_end(struct saa7146_fh *fh, struct file *file)
fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat);
/* we need to have a valid format set here */ /* we need to have a valid format set here */
BUG_ON(NULL == fmt); if (!fmt)
return -EINVAL;
if (0 != (fmt->flags & FORMAT_IS_PLANAR)) { if (0 != (fmt->flags & FORMAT_IS_PLANAR)) {
resource = RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP|RESOURCE_DMA3_BRS; resource = RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP|RESOURCE_DMA3_BRS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment