Dmitry Konyshev 1/23/09 sdr-read-fix patch to fix a crash when dumping SDRs in a file and there's an error getting an sdr. Improve algorithm for finding optimal packet size

This commit is contained in:
Carol Hebert 2009-01-28 19:54:06 +00:00
parent 928da786e5
commit 025f196aec

View File

@ -2743,14 +2743,21 @@ ipmi_sdr_get_record(struct ipmi_intf * intf, struct sdr_get_rs * header,
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
sdr_max_read_len = sdr_rq.length - 1;
if (sdr_max_read_len > 0) {
/* no response may happen if requests are bridged
and too many bytes are requested */
continue;
} else {
free(data);
return NULL;
}
}
switch (rsp->ccode) {
case 0xca:
/* read too many bytes at once */
sdr_max_read_len = (sdr_max_read_len >> 1) - 1;
sdr_max_read_len = sdr_rq.length - 1;
continue;
case 0xc5:
/* lost reservation */
@ -4037,6 +4044,11 @@ ipmi_sdr_dump_bin(struct ipmi_intf *intf, const char *ofile)
sdrr->length = header->length;
sdrr->raw = ipmi_sdr_get_record(intf, header, itr);
if (sdrr->raw == NULL) {
lprintf(LOG_ERR, "ipmitool: cannot obtain SDR record %04x", header->id);
return -1;
}
if (sdr_list_head == NULL)
sdr_list_head = sdrr;
else