mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2026-01-27 12:47:24 +01:00
media: v4l2-subdev: Fix alloc failure check in v4l2_subdev_call_state_try()
commitf37df9a0ebupstream. v4l2_subdev_call_state_try() macro allocates a subdev state with __v4l2_subdev_state_alloc(), but does not check the returned value. If __v4l2_subdev_state_alloc fails, it returns an ERR_PTR, and that would cause v4l2_subdev_call_state_try() to crash. Add proper error handling to v4l2_subdev_call_state_try(). Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Fixes:982c048718("media: subdev: Add v4l2_subdev_call_state_try() macro") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/all/aJTNtpDUbTz7eyJc%40stanley.mountain/ Cc: stable@vger.kernel.org Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
83fa857f27
commit
a553530b33
|
|
@ -1962,19 +1962,23 @@ extern const struct v4l2_subdev_ops v4l2_subdev_call_wrappers;
|
||||||
*
|
*
|
||||||
* Note: only legacy non-MC drivers may need this macro.
|
* Note: only legacy non-MC drivers may need this macro.
|
||||||
*/
|
*/
|
||||||
#define v4l2_subdev_call_state_try(sd, o, f, args...) \
|
#define v4l2_subdev_call_state_try(sd, o, f, args...) \
|
||||||
({ \
|
({ \
|
||||||
int __result; \
|
int __result; \
|
||||||
static struct lock_class_key __key; \
|
static struct lock_class_key __key; \
|
||||||
const char *name = KBUILD_BASENAME \
|
const char *name = KBUILD_BASENAME \
|
||||||
":" __stringify(__LINE__) ":state->lock"; \
|
":" __stringify(__LINE__) ":state->lock"; \
|
||||||
struct v4l2_subdev_state *state = \
|
struct v4l2_subdev_state *state = \
|
||||||
__v4l2_subdev_state_alloc(sd, name, &__key); \
|
__v4l2_subdev_state_alloc(sd, name, &__key); \
|
||||||
v4l2_subdev_lock_state(state); \
|
if (IS_ERR(state)) { \
|
||||||
__result = v4l2_subdev_call(sd, o, f, state, ##args); \
|
__result = PTR_ERR(state); \
|
||||||
v4l2_subdev_unlock_state(state); \
|
} else { \
|
||||||
__v4l2_subdev_state_free(state); \
|
v4l2_subdev_lock_state(state); \
|
||||||
__result; \
|
__result = v4l2_subdev_call(sd, o, f, state, ##args); \
|
||||||
|
v4l2_subdev_unlock_state(state); \
|
||||||
|
__v4l2_subdev_state_free(state); \
|
||||||
|
} \
|
||||||
|
__result; \
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user