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

Commit a48d5db4 authored by Alok Chauhan's avatar Alok Chauhan
Browse files

platform: msm: msm_bus: Address memory leak during client registration



Correct the client registration logic for suspected memory leak
in case of any error occurred during registration.

Change-Id: I4738b110d575a726f62a7ab458b8ec2d84d5f6d9
Signed-off-by: default avatarAlok Chauhan <alokc@codeaurora.org>
parent ca3ceb78
Loading
Loading
Loading
Loading
+13 −5
Original line number Original line Diff line number Diff line
@@ -984,7 +984,7 @@ static uint32_t register_client_adhoc(struct msm_bus_scale_pdata *pdata)
	lnode = kzalloc(pdata->usecase->num_paths * sizeof(int), GFP_KERNEL);
	lnode = kzalloc(pdata->usecase->num_paths * sizeof(int), GFP_KERNEL);
	if (ZERO_OR_NULL_PTR(lnode)) {
	if (ZERO_OR_NULL_PTR(lnode)) {
		MSM_BUS_ERR("%s: Error allocating pathnode ptr!", __func__);
		MSM_BUS_ERR("%s: Error allocating pathnode ptr!", __func__);
		goto exit_register_client;
		goto exit_lnode_malloc_fail;
	}
	}
	client->src_pnode = lnode;
	client->src_pnode = lnode;


@@ -992,7 +992,7 @@ static uint32_t register_client_adhoc(struct msm_bus_scale_pdata *pdata)
					sizeof(struct device *), GFP_KERNEL);
					sizeof(struct device *), GFP_KERNEL);
	if (IS_ERR_OR_NULL(client->src_devs)) {
	if (IS_ERR_OR_NULL(client->src_devs)) {
		MSM_BUS_ERR("%s: Error allocating pathnode ptr!", __func__);
		MSM_BUS_ERR("%s: Error allocating pathnode ptr!", __func__);
		goto exit_register_client;
		goto exit_src_dev_malloc_fail;
	}
	}
	client->curr = -1;
	client->curr = -1;


@@ -1003,7 +1003,7 @@ static uint32_t register_client_adhoc(struct msm_bus_scale_pdata *pdata)
		if ((src < 0) || (dest < 0)) {
		if ((src < 0) || (dest < 0)) {
			MSM_BUS_ERR("%s:Invalid src/dst.src %d dest %d",
			MSM_BUS_ERR("%s:Invalid src/dst.src %d dest %d",
				__func__, src, dest);
				__func__, src, dest);
			goto exit_register_client;
			goto exit_invalid_data;
		}
		}
		dev = bus_find_device(&msm_bus_type, NULL,
		dev = bus_find_device(&msm_bus_type, NULL,
				(void *) &src,
				(void *) &src,
@@ -1011,7 +1011,7 @@ static uint32_t register_client_adhoc(struct msm_bus_scale_pdata *pdata)
		if (IS_ERR_OR_NULL(dev)) {
		if (IS_ERR_OR_NULL(dev)) {
			MSM_BUS_ERR("%s:Failed to find path.src %d dest %d",
			MSM_BUS_ERR("%s:Failed to find path.src %d dest %d",
				__func__, src, dest);
				__func__, src, dest);
			goto exit_register_client;
			goto exit_invalid_data;
		}
		}
		client->src_devs[i] = dev;
		client->src_devs[i] = dev;


@@ -1019,7 +1019,7 @@ static uint32_t register_client_adhoc(struct msm_bus_scale_pdata *pdata)
		if (lnode[i] < 0) {
		if (lnode[i] < 0) {
			MSM_BUS_ERR("%s:Failed to find path.src %d dest %d",
			MSM_BUS_ERR("%s:Failed to find path.src %d dest %d",
				__func__, src, dest);
				__func__, src, dest);
			goto exit_register_client;
			goto exit_invalid_data;
		}
		}
	}
	}


@@ -1028,6 +1028,14 @@ static uint32_t register_client_adhoc(struct msm_bus_scale_pdata *pdata)
					handle);
					handle);
	MSM_BUS_DBG("%s:Client handle %d %s", __func__, handle,
	MSM_BUS_DBG("%s:Client handle %d %s", __func__, handle,
						client->pdata->name);
						client->pdata->name);
	rt_mutex_unlock(&msm_bus_adhoc_lock);
	return handle;
exit_invalid_data:
	kfree(client->src_devs);
exit_src_dev_malloc_fail:
	kfree(lnode);
exit_lnode_malloc_fail:
	kfree(client);
exit_register_client:
exit_register_client:
	rt_mutex_unlock(&msm_bus_adhoc_lock);
	rt_mutex_unlock(&msm_bus_adhoc_lock);
	return handle;
	return handle;