Produce an error if kmalloc() fails.
Signed-off-by: Roel Kluin <[email protected]>
---
Found with sed: http://kernelnewbies.org/roelkluin
Build tested. Please review
diff --git a/drivers/media/video/uvc/uvc_ctrl.c
b/drivers/media/video/uvc/uvc_ctrl.c
index c3225a5..dda80b5 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -1189,7 +1189,7 @@ int uvc_ctrl_resume_device(struct uvc_device *dev)
* Control and mapping handling
*/
-static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
+static int uvc_ctrl_add_ctrl(struct uvc_device *dev,
struct uvc_control_info *info)
{
struct uvc_entity *entity;
@@ -1214,7 +1214,7 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
}
if (!found)
- return;
+ return 0;
if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT) {
/* Check if the device control information and length match
@@ -1231,7 +1231,7 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
"control " UVC_GUID_FORMAT "/%u (%d).\n",
UVC_GUID_ARGS(info->entity), info->selector,
ret);
- return;
+ return -EINVAL;
}
if (info->size != le16_to_cpu(size)) {
@@ -1239,7 +1239,7 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
"/%u size doesn't match user supplied "
"value.\n", UVC_GUID_ARGS(info->entity),
info->selector);
- return;
+ return -EINVAL;
}
ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id,
@@ -1249,7 +1249,7 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
"control " UVC_GUID_FORMAT "/%u (%d).\n",
UVC_GUID_ARGS(info->entity), info->selector,
ret);
- return;
+ return -EINVAL;
}
flags = info->flags;
@@ -1259,15 +1259,18 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
UVC_GUID_FORMAT "/%u flags don't match "
"supported operations.\n",
UVC_GUID_ARGS(info->entity), info->selector);
- return;
+ return -EINVAL;
}
}
ctrl->info = info;
ctrl->data = kmalloc(ctrl->info->size * UVC_CTRL_NDATA, GFP_KERNEL);
+ if (ctrl->data == NULL)
+ return -ENOMEM;
uvc_trace(UVC_TRACE_CONTROL, "Added control " UVC_GUID_FORMAT "/%u "
"to device %s entity %u\n", UVC_GUID_ARGS(ctrl->info->entity),
ctrl->info->selector, dev->udev->devpath, entity->id);
+ return 0;
}
/*
@@ -1309,8 +1312,11 @@ int uvc_ctrl_add_info(struct uvc_control_info *info)
}
}
- list_for_each_entry(dev, &uvc_driver.devices, list)
- uvc_ctrl_add_ctrl(dev, info);
+ list_for_each_entry(dev, &uvc_driver.devices, list) {
+ ret = uvc_ctrl_add_ctrl(dev, info);
+ if (ret == -ENOMEM)
+ goto end;
+ }
INIT_LIST_HEAD(&info->mappings);
list_add_tail(&info->list, &uvc_driver.controls);
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html