X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH] platform/x86/intel/pmc: Fix ioremap of bad address
@ 2025-01-06 17:46 David E. Box
  2025-01-07 15:59 ` Ilpo Järvinen
  0 siblings, 1 reply; 2+ messages in thread
From: David E. Box @ 2025-01-06 17:46 UTC (permalink / raw)
  To: irenic.rajneesh, david.e.box, ilpo.jarvinen, hdegoede,
	platform-driver-x86, linux-kernel, xi.pardee
  Cc: David E. Box

In pmc_core_ssram_get_pmc(), the physical addresses for hidden SSRAM
devices are retrieved from the MMIO region of the primary SSRAM device. If
additional devices are not present, the address returned is zero.
Currently, the code does not check for this condition, resulting in ioremap
incorrectly attempting to map address 0. Add a check for a zero address and
return 0 if no additional devices are found, as it is not an error for the
device to be absent.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Fixes: a01486dc4bb1 ("platform/x86/intel/pmc: Cleanup SSRAM discovery")
---
 drivers/platform/x86/intel/pmc/core_ssram.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c b/drivers/platform/x86/intel/pmc/core_ssram.c
index 50ebfd586d3f..739569803017 100644
--- a/drivers/platform/x86/intel/pmc/core_ssram.c
+++ b/drivers/platform/x86/intel/pmc/core_ssram.c
@@ -269,8 +269,12 @@ pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, int pmc_idx, u32 offset)
 		/*
 		 * The secondary PMC BARS (which are behind hidden PCI devices)
 		 * are read from fixed offsets in MMIO of the primary PMC BAR.
+		 * If a device is not present, the value will be 0.
 		 */
 		ssram_base = get_base(tmp_ssram, offset);
+		if (!ssram_base)
+			return 0;
+
 		ssram = ioremap(ssram_base, SSRAM_HDR_SIZE);
 		if (!ssram)
 			return -ENOMEM;

base-commit: 6b228cfc52a6e9b7149cf51e247076963d6561cd
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-07 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-06 17:46 [PATCH] platform/x86/intel/pmc: Fix ioremap of bad address David E. Box
2025-01-07 15:59 ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox