Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f09e00fd authored by Jeyaprakash Soundrapandian's avatar Jeyaprakash Soundrapandian Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: cpas: Add protection for concurrent execution" into dev/msm-4.14-camx

parents a0694e41 c52e1e3e
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -1214,17 +1214,26 @@ static int cam_cpas_hw_register_client(struct cam_hw_info *cpas_hw,

	rc = cam_common_util_get_string_index(soc_private->client_name,
		soc_private->num_clients, client_name, &client_indx);

	mutex_lock(&cpas_core->client_mutex[client_indx]);

	if (rc || !CAM_CPAS_CLIENT_VALID(client_indx) ||
		CAM_CPAS_CLIENT_REGISTERED(cpas_core, client_indx)) {
		CAM_ERR(CAM_CPAS, "Invalid Client register : %s %d, %d",
		CAM_ERR(CAM_CPAS,
			"Inval client %s %d : %d %d %pK %d",
			register_params->identifier,
			register_params->cell_index, client_indx);
			register_params->cell_index,
			CAM_CPAS_CLIENT_VALID(client_indx),
			CAM_CPAS_CLIENT_REGISTERED(cpas_core, client_indx),
			cpas_core->cpas_client[client_indx], rc);
		mutex_unlock(&cpas_core->client_mutex[client_indx]);
		mutex_unlock(&cpas_hw->hw_mutex);
		return -EPERM;
	}

	cpas_client = kzalloc(sizeof(struct cam_cpas_client), GFP_KERNEL);
	if (!cpas_client) {
		mutex_unlock(&cpas_core->client_mutex[client_indx]);
		mutex_unlock(&cpas_hw->hw_mutex);
		return -ENOMEM;
	}
@@ -1237,6 +1246,7 @@ static int cam_cpas_hw_register_client(struct cam_hw_info *cpas_hw,
			client_indx, cpas_client->data.identifier,
			cpas_client->data.cell_index, rc);
		kfree(cpas_client);
		mutex_unlock(&cpas_core->client_mutex[client_indx]);
		mutex_unlock(&cpas_hw->hw_mutex);
		return -EINVAL;
	}
@@ -1248,12 +1258,13 @@ static int cam_cpas_hw_register_client(struct cam_hw_info *cpas_hw,
	cpas_core->cpas_client[client_indx] = cpas_client;
	cpas_core->registered_clients++;

	mutex_unlock(&cpas_hw->hw_mutex);

	CAM_DBG(CAM_CPAS, "client=[%d][%s][%d], registered_clients=%d",
		client_indx, cpas_client->data.identifier,
		cpas_client->data.cell_index, cpas_core->registered_clients);

	mutex_unlock(&cpas_core->client_mutex[client_indx]);
	mutex_unlock(&cpas_hw->hw_mutex);

	return 0;
}

+1 −0
Original line number Diff line number Diff line
@@ -619,6 +619,7 @@ static int cam_cpas_dev_remove(struct platform_device *dev)
	}

	mutex_lock(&g_cpas_intf->intf_lock);
	g_cpas_intf->probe_done = false;
	cam_unregister_subdev(&g_cpas_intf->subdev);
	cam_cpas_hw_remove(g_cpas_intf->hw_intf);
	mutex_unlock(&g_cpas_intf->intf_lock);