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

Commit 8a5fa876 authored by Jiacheng Zheng's avatar Jiacheng Zheng
Browse files

soc: qcom: subsys-pil-tz: fix resource leak problem



msm_bus_client resource is allocated in piltz_resc_init. So
if pil_tz_driver_probe fails somewhere after piltz_resc_init,
we need to call msm_bus_scale_unregister_client to release
the msm_bus_client resource allocated earlier.

Change-Id: If68f2d4b447de15a8b1fd1d68d403ffaf5a6c6d5
Signed-off-by: default avatarJiacheng Zheng <jiaczhen@codeaurora.org>
parent d4bea3de
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * 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
 * it under the terms of the GNU General Public License version 2 and
@@ -422,6 +422,12 @@ static int piltz_resc_init(struct platform_device *pdev, struct pil_tz_data *d)
	return 0;
	return 0;
}
}


static void piltz_resc_destroy(struct pil_tz_data *d)
{
	if (d->bus_client)
		msm_bus_scale_unregister_client(d->bus_client);
}

static int enable_regulators(struct pil_tz_data *d, struct device *dev,
static int enable_regulators(struct pil_tz_data *d, struct device *dev,
				struct reg_info *regs, int reg_count,
				struct reg_info *regs, int reg_count,
				bool reg_no_enable)
				bool reg_no_enable)
@@ -1145,7 +1151,7 @@ static int pil_tz_driver_probe(struct platform_device *pdev)


	rc = pil_desc_init(&d->desc);
	rc = pil_desc_init(&d->desc);
	if (rc)
	if (rc)
		return rc;
		goto err_descinit;


	init_completion(&d->stop_ack);
	init_completion(&d->stop_ack);


@@ -1273,6 +1279,8 @@ static int pil_tz_driver_probe(struct platform_device *pdev)
err_ramdump:
err_ramdump:
	pil_desc_release(&d->desc);
	pil_desc_release(&d->desc);
	platform_set_drvdata(pdev, NULL);
	platform_set_drvdata(pdev, NULL);
err_descinit:
	piltz_resc_destroy(d);


	return rc;
	return rc;
}
}