diff mbox

platform: set default bmc_platform

Message ID 1484282021-23741-1-git-send-email-oohall@gmail.com
State Accepted
Headers show

Commit Message

Oliver O'Halloran Jan. 13, 2017, 4:33 a.m. UTC
The bmc_platform pointer is set to NULL by default and on non-AMI BMC
platforms. As a result a few places in hw/ipmi/ipmi-sel.c will blindly
dereference a NULL pointer.

This patch sets the default value for bmc_platform to generic_bmc to
avoid this.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 core/platform.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Stewart Smith Jan. 16, 2017, 2:38 a.m. UTC | #1
Oliver O'Halloran <oohall@gmail.com> writes:
> The bmc_platform pointer is set to NULL by default and on non-AMI BMC
> platforms. As a result a few places in hw/ipmi/ipmi-sel.c will blindly
> dereference a NULL pointer.
>
> This patch sets the default value for bmc_platform to generic_bmc to
> avoid this.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>  core/platform.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Thanks! I was casually sure I dealt with this case when I first wrote
it... but perhaps I didn't, and I can't remember a reason why I wouldn't
have.

So, well, merged to master as of e0f184b6eaf9e302cd1366042d37d7af968e38e9
diff mbox

Patch

diff --git a/core/platform.c b/core/platform.c
index bde3932d3cc1..1cae06915d65 100644
--- a/core/platform.c
+++ b/core/platform.c
@@ -28,7 +28,6 @@ 
 
 bool manufacturing_mode = false;
 struct platform	platform;
-const struct bmc_platform *bmc_platform = NULL;
 
 DEFINE_LOG_ENTRY(OPAL_RC_ABNORMAL_REBOOT, OPAL_PLATFORM_ERR_EVT, OPAL_CEC,
 		 OPAL_CEC_HARDWARE, OPAL_PREDICTIVE_ERR_FAULT_RECTIFY_REBOOT,
@@ -143,10 +142,15 @@  static struct platform generic_platform = {
 	.cec_power_down	= generic_cec_power_down,
 };
 
+const struct bmc_platform *bmc_platform = &generic_bmc;
+
 void set_bmc_platform(const struct bmc_platform *bmc)
 {
 	if (bmc)
 		prlog(PR_NOTICE, "PLAT: Detected BMC platform %s\n", bmc->name);
+	else
+		bmc = &generic_bmc;
+
 	bmc_platform = bmc;
 }