When uses the wrong resource control id by client, crash happen
because the invalid array index is used. In order to prevent crash
issue, check the validation of resource control id.
Change-Id: I621757bb17b054dafb246ceac57d3eabf419fc31
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
int ctrl_index = RESOURCE_CTRL_INDEX(ctrl_id);
int ret;
- if (!resource) {
+ if (!resource || ctrl_index < 0 || ctrl_index >= resource->num_ctrls) {
_E("Invalid parameter\n");
return -EINVAL;
}
const struct resource_control *ctrl;
int ctrl_index = RESOURCE_CTRL_INDEX(ctrl_id);
- if (!resource)
+ if (!resource || ctrl_index < 0 || ctrl_index >= resource->num_ctrls) {
+ _E("Invalid parameter\n");
return NULL;
+ }
+
ctrl = &resource->ctrls[ctrl_index];
return ctrl->name;