@@ -1842,7 +1842,8 @@ static int uvc_ctrl_init_xu_ctrl(struct uvc_device *dev,
int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
struct uvc_xu_control_query *xqry)
{
- struct uvc_entity *entity;
+ struct uvc_entity *entity = NULL;
+ struct uvc_entity *cursor = NULL;
struct uvc_control *ctrl;
unsigned int i, found = 0;
u32 reqflags;
@@ -1851,13 +1852,15 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
int ret;
/* Find the extension unit. */
- list_for_each_entry(entity, &chain->entities, chain) {
- if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT &&
- entity->id == xqry->unit)
+ list_for_each_entry(cursor, &chain->entities, chain) {
+ if (UVC_ENTITY_TYPE(cursor) == UVC_VC_EXTENSION_UNIT &&
+ cursor->id == xqry->unit) {
+ entity = cursor;
break;
+ }
}
- if (entity->id != xqry->unit) {
+ if (!entity || entity->id != xqry->unit) {
uvc_trace(UVC_TRACE_CONTROL, "Extension unit %u not found.\n",
xqry->unit);
return -ENOENT;