diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2022-08-26 13:53:58 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2022-09-24 09:05:02 +0200 |
commit | 2ba3e38517f5a4ebf9c997168079dca01b7f9fc6 (patch) | |
tree | b10b59cdb23a34d9d5b63b9c59b42a709d17a452 /include | |
parent | media: ipu3-imgu: Fix NULL pointer dereference in active selection access (diff) | |
download | linux-2ba3e38517f5a4ebf9c997168079dca01b7f9fc6.tar.xz linux-2ba3e38517f5a4ebf9c997168079dca01b7f9fc6.zip |
media: v4l: subdev: Fail graciously when getting try data for NULL state
The state argument for the functions for obtaining various parts of the
state is NULL if it is called by drivers for active state. Fail graciously
in that case instead of dereferencing a NULL pointer.
Suggested-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/media/v4l2-subdev.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 9689f38a0af1..ec1896886dbd 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1046,6 +1046,8 @@ v4l2_subdev_get_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, unsigned int pad) { + if (WARN_ON(!state)) + return NULL; if (WARN_ON(pad >= sd->entity.num_pads)) pad = 0; return &state->pads[pad].try_fmt; @@ -1064,6 +1066,8 @@ v4l2_subdev_get_pad_crop(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, unsigned int pad) { + if (WARN_ON(!state)) + return NULL; if (WARN_ON(pad >= sd->entity.num_pads)) pad = 0; return &state->pads[pad].try_crop; @@ -1082,6 +1086,8 @@ v4l2_subdev_get_pad_compose(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, unsigned int pad) { + if (WARN_ON(!state)) + return NULL; if (WARN_ON(pad >= sd->entity.num_pads)) pad = 0; return &state->pads[pad].try_compose; |