summaryrefslogtreecommitdiff
path: root/lib/ipmi_kontronoem.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-02-20 02:12:42 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-02-20 02:12:42 +0100
commita61a5992cefc2204a99f25b2395b108092098e2c (patch)
tree3b25da535866adf0458f6d172fd242fc933c77db /lib/ipmi_kontronoem.c
parent15edf42f095e3cc26e372547ebcaaae558d0cce2 (diff)
parent97d6a2e491c6ed08473beb2c4bac47c5cbc1201a (diff)
Merge tag 'upstream/1.8.16'
Upstream version 1.8.16
Diffstat (limited to 'lib/ipmi_kontronoem.c')
-rw-r--r--lib/ipmi_kontronoem.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/lib/ipmi_kontronoem.c b/lib/ipmi_kontronoem.c
index 48dc684..64860be 100644
--- a/lib/ipmi_kontronoem.c
+++ b/lib/ipmi_kontronoem.c
@@ -105,7 +105,7 @@ ipmi_kontronoem_main(struct ipmi_intf *intf, int argc, char **argv)
if (argc < 2) {
lprintf(LOG_ERR, "Not enough parameters given.");
ipmi_kontron_nextboot_help();
- rc = (-1);
+ return (-1);
}
rc = ipmi_kontron_nextboot_set(intf, (argc - 1), (argv + 1));
if (rc == 0) {
@@ -176,7 +176,6 @@ ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf *intf,
struct ipmi_rs *rsp;
struct ipmi_rq req;
uint8_t msg_data[2];
- int i;
memset(msg_data, 0, sizeof(msg_data));
/* channel =~ 0x0e => Currently running interface */
msg_data[0] = channel;
@@ -347,11 +346,28 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
/* Position at Board Manufacturer */
fru_data_offset = (header.offset.board * 8) + 6;
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
+ if (fru_area != NULL) {
+ free(fru_area);
+ fru_area = NULL;
+ }
/* Position at Board Product Name */
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
+ if (fru_area != NULL) {
+ free(fru_area);
+ fru_area = NULL;
+ }
fru_data_offset_tmp = fru_data_offset;
/* Position at Serial Number */
fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp);
+ if (fru_area == NULL) {
+ lprintf(LOG_ERR, "Failed to read FRU Area string.");
+ free(fru_data);
+ fru_data = NULL;
+ free(sn);
+ sn = NULL;
+ return (-1);
+ }
+
fru_data_offset++;
if (strlen(fru_area) != sn_size) {
printf("The length of the serial number in the FRU Board Area is wrong.\n");
@@ -359,7 +375,12 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
sn = NULL;
free(fru_data);
fru_data = NULL;
+ free(fru_area);
+ fru_area = NULL;
return(-1);
+ } else {
+ free(fru_area);
+ fru_area = NULL;
}
/* Copy the new serial number in the board section saved in memory*/
memcpy(fru_data + fru_data_offset, sn, sn_size);
@@ -380,6 +401,8 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
sn = NULL;
free(fru_data);
fru_data = NULL;
+ free(fru_area);
+ fru_area = NULL;
return(-1);
}
/* Set the Product Section */
@@ -390,26 +413,54 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
sn = NULL;
free(fru_data);
fru_data = NULL;
+ free(fru_area);
+ fru_area = NULL;
return(-1);
}
/* Position at Product Manufacturer */
fru_data_offset = (header.offset.product * 8) + 3;
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
+ if (fru_area != NULL) {
+ free(fru_area);
+ fru_area = NULL;
+ }
/* Position at Product Name */
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
+ if (fru_area != NULL) {
+ free(fru_area);
+ fru_area = NULL;
+ }
/* Position at Product Part */
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
+ if (fru_area != NULL) {
+ free(fru_area);
+ fru_area = NULL;
+ }
/* Position at Product Version */
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
+ if (fru_area != NULL) {
+ free(fru_area);
+ fru_area = NULL;
+ }
fru_data_offset_tmp = fru_data_offset;
/* Position at Serial Number */
fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp);
+ if (fru_area == NULL) {
+ lprintf(LOG_ERR, "Failed to read FRU Area string.");
+ free(sn);
+ sn = NULL;
+ free(fru_data);
+ fru_data = NULL;
+ return (-1);
+ }
fru_data_offset ++;
if (strlen(fru_area) != sn_size) {
free(sn);
sn = NULL;
free(fru_data);
fru_data = NULL;
+ free(fru_area);
+ fru_area = NULL;
printf("The length of the serial number in the FRU Product Area is wrong.\n");
return(-1);
}
@@ -432,12 +483,16 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
sn = NULL;
free(fru_data);
fru_data = NULL;
+ free(fru_area);
+ fru_area = NULL;
return -1;
}
free(sn);
sn = NULL;
free(fru_data);
fru_data = NULL;
+ free(fru_area);
+ fru_area = NULL;
return(1);
}