Correctly handle potential buffer malloc() failure in HIOMAP write window request

parent ef7fc2b2
......@@ -72,6 +72,7 @@
#define IPMI_CC_NO_ERROR 0x00
#define IPMI_CC_SNS_NOT_PRSNT 0xcb
#define IPMI_CC_INVALID_COMMAND 0xc1
#define IPMI_CC_OUT_OF_SPACE 0xc4
#define BASE_IPMI_REQUEST_LENGTH 3
#define BASE_IPMI_RESPONSE_LENGTH 4
......
......@@ -1544,6 +1544,13 @@ static int process_host_to_bmc_ipmi_bt_transactions(void)
hiomap_config.write_windows[hiomap_config.write_window_count].start_address = hiomap_config.window_start_address;
hiomap_config.write_windows[hiomap_config.write_window_count].bytes = hiomap_config.window_length_bytes;
hiomap_config.write_windows[hiomap_config.write_window_count].buffer = malloc(FLASH_MAX_WR_WINDOW_BYTES);
if (hiomap_config.write_windows[hiomap_config.write_window_count].buffer == NULL)
{
KESTREL_LOG("[ERROR] Unable to allocate HIOMAP buffer space!\n");
response.length = BASE_IPMI_RESPONSE_LENGTH;
response.completion_code = IPMI_CC_OUT_OF_SPACE;
break;
}
hiomap_config.write_windows[hiomap_config.write_window_count].active = 1;
hiomap_write_buffer = hiomap_config.write_windows[hiomap_config.write_window_count].buffer;
hiomap_config.write_window_count++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment