Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1432801

[PATCH 3/6] soc/tegra: pmc: Don't populate soc data until register space is mapped

From Jon Hunter <jonathanh@nvidia.com>
Newsgroups linux.kernel
Subject [PATCH 3/6] soc/tegra: pmc: Don't populate soc data until register space is mapped
Date 2016-06-28 12:50 +0200
Message-ID <rOYKD-5Nk-65@gated-at.bofh.it> (permalink)
References <rOYKC-5Nk-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The public functions exported by the PMC driver use the presence of the
soc data pointer to determine if the PMC device is configured and the
registers can be accessed. However, the soc data is populated before the
PMC register space is mapped and this opens a window where the soc data
pointer is valid but the register space has not yet been mapped which
could lead to a crash. Furthermore, if the mapping of the PMC register
space fails, then the soc data pointer is not cleared and so would
expose a larger window where a crash could occur.

Fix this by initialising the soc data pointer after the PMC register
space has been mapped.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
 drivers/soc/tegra/pmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 2e031c4ad547..ed2b2c83e4eb 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -1540,8 +1540,6 @@ static int __init tegra_pmc_early_init(void)
 			pr_err("failed to get PMC registers\n");
 			return -ENXIO;
 		}
-
-		pmc->soc = match->data;
 	}
 
 	pmc->base = ioremap_nocache(regs.start, resource_size(&regs));
@@ -1553,6 +1551,8 @@ static int __init tegra_pmc_early_init(void)
 	mutex_init(&pmc->powergates_lock);
 
 	if (np) {
+		pmc->soc = match->data;
+
 		/* Create a bit-map of the available and valid partitions */
 		for (i = 0; i < pmc->soc->num_powergates; i++)
 			if (pmc->soc->powergates[i])
-- 
2.1.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] soc/tegra: Various PMC fixes Jon Hunter <jonathanh@nvidia.com> - 2016-06-28 12:50 +0200
  [PATCH 4/6] soc/tegra: pmc: Ensure mutex is always initialised Jon Hunter <jonathanh@nvidia.com> - 2016-06-28 12:50 +0200
  [PATCH 3/6] soc/tegra: pmc: Don't populate soc data until register space is mapped Jon Hunter <jonathanh@nvidia.com> - 2016-06-28 12:50 +0200
  [PATCH 6/6] soc/tegra: pmc: Don't probe pmc if early initialisation fails Jon Hunter <jonathanh@nvidia.com> - 2016-06-28 12:50 +0200
  [PATCH 5/6] soc/tegra: pmc: Add missing of_node_put Jon Hunter <jonathanh@nvidia.com> - 2016-06-28 12:50 +0200
  [PATCH 2/6] soc/tegra: pmc: Fix early initialisation of PMC Jon Hunter <jonathanh@nvidia.com> - 2016-06-28 12:50 +0200
    Re: [PATCH 2/6] soc/tegra: pmc: Fix early initialisation of PMC Jon Hunter <jonathanh@nvidia.com> - 2016-06-29 18:20 +0200
      Re: [PATCH 2/6] soc/tegra: pmc: Fix early initialisation of PMC Thierry Reding <thierry.reding@gmail.com> - 2016-06-30 12:10 +0200
  Re: [PATCH 0/6] soc/tegra: Various PMC fixes Thierry Reding <thierry.reding@gmail.com> - 2016-06-30 12:10 +0200

csiph-web