Skip to content

Commit

Permalink
media: amphion: fix REVERSE_INULL issues reported by coverity
Browse files Browse the repository at this point in the history
[ Upstream commit 79d3baf ]

null-checking of a pointor is suggested before dereferencing it

Fixes: 9f599f3 ("media: amphion: add vpu core driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
mingqian-0 authored and gregkh committed Sep 13, 2023
1 parent 3930d62 commit bddd678
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/media/platform/amphion/venc.c
Expand Up @@ -278,7 +278,7 @@ static int venc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *parm
{
struct vpu_inst *inst = to_inst(file);
struct venc_t *venc = inst->priv;
struct v4l2_fract *timeperframe = &parm->parm.capture.timeperframe;
struct v4l2_fract *timeperframe;

if (!parm)
return -EINVAL;
Expand All @@ -289,6 +289,7 @@ static int venc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *parm
if (!vpu_helper_check_type(inst, parm->type))
return -EINVAL;

timeperframe = &parm->parm.capture.timeperframe;
parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
parm->parm.capture.readbuffers = 0;
timeperframe->numerator = venc->params.frame_rate.numerator;
Expand All @@ -301,7 +302,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *parm
{
struct vpu_inst *inst = to_inst(file);
struct venc_t *venc = inst->priv;
struct v4l2_fract *timeperframe = &parm->parm.capture.timeperframe;
struct v4l2_fract *timeperframe;
unsigned long n, d;

if (!parm)
Expand All @@ -313,6 +314,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *parm
if (!vpu_helper_check_type(inst, parm->type))
return -EINVAL;

timeperframe = &parm->parm.capture.timeperframe;
if (!timeperframe->numerator)
timeperframe->numerator = venc->params.frame_rate.numerator;
if (!timeperframe->denominator)
Expand Down

0 comments on commit bddd678

Please sign in to comment.