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

Commit b4d20c5e authored by Mahesh Voorugonda's avatar Mahesh Voorugonda
Browse files

msm: vidc: Fix concurrency issues in bus voting



when concurrent sessions are running, vote data of current
instance is getting reset due to next subsequent call.
Avoid sharing common vote data structure to avoid race-condition.

Change-Id: Ie188edf2619dc8f26a4d43093fd0cda4d4113737
Signed-off-by: default avatarMahesh Voorugonda <mvooru@codeaurora.org>
parent ba2be1b1
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -184,13 +184,17 @@ int msm_comm_vote_bus(struct msm_vidc_core *core)
	hdev = core->device;

	mutex_lock(&core->lock);
	vote_data = core->vote_data;
	list_for_each_entry(inst, &core->instances, list)
		++vote_data_count;

	vote_data = kcalloc(vote_data_count, sizeof(*vote_data),
			GFP_TEMPORARY);
	vote_data_count = 0;
	if (!vote_data) {
		dprintk(VIDC_PROF,
			"Failed to get vote_data for inst %pK\n",
				inst);
		dprintk(VIDC_ERR, "%s: failed to allocate memory\n", __func__);
		mutex_unlock(&core->lock);
		return -EINVAL;
		rc = -ENOMEM;
		return rc;
	}

	list_for_each_entry(inst, &core->instances, list) {
@@ -303,6 +307,7 @@ int msm_comm_vote_bus(struct msm_vidc_core *core)
		rc = call_hfi_op(hdev, vote_bus, hdev->hfi_device_data,
			vote_data, vote_data_count);

	kfree(vote_data);
	return rc;
}