From 740a089c51d1b30412d0486d50b1b4dc9a995be8 Mon Sep 17 00:00:00 2001 From: Gustavo de Souza dos Reis Date: Mon, 21 Aug 2023 14:06:54 -0300 Subject: [PATCH] Fix IPMI FRU Write command returning invalid data --- modules/fru.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/fru.c b/modules/fru.c index 2a22a43aa..c4a469207 100644 --- a/modules/fru.c +++ b/modules/fru.c @@ -260,7 +260,7 @@ size_t fru_write( uint8_t id, uint8_t *tx_buff, uint16_t offset, size_t len ) memcpy( &fru[id].buffer[offset], tx_buff, len ); ret_val = len; } else { - ret_val = fru[id].cfg.write_f( fru[id].cfg.eeprom_id, offset, tx_buff, len, 0 ); + ret_val = fru[id].cfg.write_f( fru[id].cfg.eeprom_id, offset, tx_buff, len, 10 ); } return ret_val; } @@ -341,5 +341,15 @@ IPMI_HANDLER(ipmi_storage_write_fru_data_cmd, NETFN_STORAGE, IPMI_WRITE_FRU_DATA rsp->data[len++] = 0; rsp->completion_code = IPMI_CC_PARAM_OUT_OF_RANGE; } + + /* + * If count == 0, it may indicate that the fru_write function + * failed somehow. + */ + + if (count == 0) { + rsp->completion_code = IPMI_CC_UNSPECIFIED_ERROR; + return ; + } rsp->data_len = len; }