Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / drivers / media / video / uvc / uvc_ctrl.c
index 254d326..47c3a55 100644 (file)
@@ -1698,6 +1698,13 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
                goto done;
        }
 
+       /* Validate the user-provided bit-size and offset */
+       if (mapping->size > 32 ||
+           mapping->offset + mapping->size > ctrl->info.size * 8) {
+               ret = -EINVAL;
+               goto done;
+       }
+
        list_for_each_entry(map, &ctrl->info.mappings, list) {
                if (mapping->id == map->id) {
                        uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', "