Message ID | 20240828222932.1279508-8-xi.pardee@linux.intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Create Intel PMC SSRAM Telemetry driver | expand |
On Wed, 28 Aug 2024, Xi Pardee wrote: > Check the return value of ioremap operation and return ENOMEM when > the operation fails for better error handling. > > Signed-off-by: Xi Pardee <xi.pardee@linux.intel.com> > --- > drivers/platform/x86/intel/pmc/ssram_telemetry.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/platform/x86/intel/pmc/ssram_telemetry.c b/drivers/platform/x86/intel/pmc/ssram_telemetry.c > index 73c727042ca6..f625d39d1aa3 100644 > --- a/drivers/platform/x86/intel/pmc/ssram_telemetry.c > +++ b/drivers/platform/x86/intel/pmc/ssram_telemetry.c > @@ -84,6 +84,9 @@ pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, unsigned int pmc_idx, u32 offset) > ssram_base = ssram_pcidev->resource[0].start; > tmp_ssram = ioremap(ssram_base, SSRAM_HDR_SIZE); > > + if (!tmp_ssram) > + return -ENOMEM; > + > if (pmc_idx != PMC_IDX_MAIN) { > /* > * The secondary PMC BARS (which are behind hidden PCI devices) Is this a fix to the current code? And should have Fixes tag and go first because of that?
On 8/29/2024 4:06 AM, Ilpo Järvinen wrote: > On Wed, 28 Aug 2024, Xi Pardee wrote: > >> Check the return value of ioremap operation and return ENOMEM when >> the operation fails for better error handling. >> >> Signed-off-by: Xi Pardee <xi.pardee@linux.intel.com> >> --- >> drivers/platform/x86/intel/pmc/ssram_telemetry.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/platform/x86/intel/pmc/ssram_telemetry.c b/drivers/platform/x86/intel/pmc/ssram_telemetry.c >> index 73c727042ca6..f625d39d1aa3 100644 >> --- a/drivers/platform/x86/intel/pmc/ssram_telemetry.c >> +++ b/drivers/platform/x86/intel/pmc/ssram_telemetry.c >> @@ -84,6 +84,9 @@ pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, unsigned int pmc_idx, u32 offset) >> ssram_base = ssram_pcidev->resource[0].start; >> tmp_ssram = ioremap(ssram_base, SSRAM_HDR_SIZE); >> >> + if (!tmp_ssram) >> + return -ENOMEM; >> + >> if (pmc_idx != PMC_IDX_MAIN) { >> /* >> * The secondary PMC BARS (which are behind hidden PCI devices) > Is this a fix to the current code? And should have Fixes tag and go > first because of that? This is an improvement of the current code. We should check the value of ioremap before using it to avoid failure in the later process. I can add a fixes tag to it. Should this patch be its own patch series and not include in this one? Or should it be moved to be the first patch of this series? Thanks! Xi >
diff --git a/drivers/platform/x86/intel/pmc/ssram_telemetry.c b/drivers/platform/x86/intel/pmc/ssram_telemetry.c index 73c727042ca6..f625d39d1aa3 100644 --- a/drivers/platform/x86/intel/pmc/ssram_telemetry.c +++ b/drivers/platform/x86/intel/pmc/ssram_telemetry.c @@ -84,6 +84,9 @@ pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, unsigned int pmc_idx, u32 offset) ssram_base = ssram_pcidev->resource[0].start; tmp_ssram = ioremap(ssram_base, SSRAM_HDR_SIZE); + if (!tmp_ssram) + return -ENOMEM; + if (pmc_idx != PMC_IDX_MAIN) { /* * The secondary PMC BARS (which are behind hidden PCI devices)
Check the return value of ioremap operation and return ENOMEM when the operation fails for better error handling. Signed-off-by: Xi Pardee <xi.pardee@linux.intel.com> --- drivers/platform/x86/intel/pmc/ssram_telemetry.c | 3 +++ 1 file changed, 3 insertions(+)