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

Commit 2bc44873 authored by Tatenda Chipeperekwa's avatar Tatenda Chipeperekwa
Browse files

drm/msm/dp: fix controller and parser sub module cleanup



Assign the device pointer during the controller module
initialization in order to prevent a potential null
pointer dereference when the module is destroyed.
Furthermore, in the parser module, ensure that the
components for each power module are cleaned up
appropriately in cases when they are assigned and valid.

CRs-Fixed: 2129828
Change-Id: I62711fde7a094834d1e672ebce40e8204544339f
Signed-off-by: default avatarTatenda Chipeperekwa <tatendac@codeaurora.org>
parent 3fafba6f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1442,6 +1442,7 @@ struct dp_ctrl *dp_ctrl_get(struct dp_ctrl_in *in)
	ctrl->aux      = in->aux;
	ctrl->link     = in->link;
	ctrl->catalog  = in->catalog;
	ctrl->dev  = in->dev;

	dp_ctrl = &ctrl->dp_ctrl;

+19 −5
Original line number Diff line number Diff line
@@ -438,6 +438,22 @@ static void dp_parser_put_clk_data(struct device *dev,
	mp->num_clk = 0;
}

static void dp_parser_put_gpio_data(struct device *dev,
	struct dss_module_power *mp)
{
	if (!mp) {
		DEV_ERR("%s: invalid input\n", __func__);
		return;
	}

	if (mp->gpio_config) {
		devm_kfree(dev, mp->gpio_config);
		mp->gpio_config = NULL;
	}

	mp->num_gpio = 0;
}

static int dp_parser_init_clk_data(struct dp_parser *parser)
{
	int num_clk = 0, i = 0, rc = 0;
@@ -634,11 +650,9 @@ void dp_parser_put(struct dp_parser *parser)
	power = parser->mp;

	for (i = 0; i < DP_MAX_PM; i++) {
		struct dss_module_power *mp = &power[i];

		devm_kfree(&parser->pdev->dev, mp->clk_config);
		devm_kfree(&parser->pdev->dev, mp->vreg_config);
		devm_kfree(&parser->pdev->dev, mp->gpio_config);
		dp_parser_put_clk_data(&parser->pdev->dev, &power[i]);
		dp_parser_put_vreg_data(&parser->pdev->dev, &power[i]);
		dp_parser_put_gpio_data(&parser->pdev->dev, &power[i]);
	}

	devm_kfree(&parser->pdev->dev, parser);