mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
ipmi:ssif: Fix handling of multi-part return messages
commit 7d6380cd40
upstream.
The block number was not being compared right, it was off by one
when checking the response.
Some statistics wouldn't be incremented properly in some cases.
Check to see if that middle-part messages always have 31 bytes of
data.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: stable@vger.kernel.org # 4.4
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
413cb66bbb
commit
7c307d3217
1 changed files with 17 additions and 8 deletions
|
@ -645,8 +645,9 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
|
|||
|
||||
/* Remove the multi-part read marker. */
|
||||
len -= 2;
|
||||
data += 2;
|
||||
for (i = 0; i < len; i++)
|
||||
ssif_info->data[i] = data[i+2];
|
||||
ssif_info->data[i] = data[i];
|
||||
ssif_info->multi_len = len;
|
||||
ssif_info->multi_pos = 1;
|
||||
|
||||
|
@ -674,8 +675,19 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
|
|||
}
|
||||
|
||||
blocknum = data[0];
|
||||
len--;
|
||||
data++;
|
||||
|
||||
if (ssif_info->multi_len + len - 1 > IPMI_MAX_MSG_LENGTH) {
|
||||
if (blocknum != 0xff && len != 31) {
|
||||
/* All blocks but the last must have 31 data bytes. */
|
||||
result = -EIO;
|
||||
if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
|
||||
pr_info("Received middle message <31\n");
|
||||
|
||||
goto continue_op;
|
||||
}
|
||||
|
||||
if (ssif_info->multi_len + len > IPMI_MAX_MSG_LENGTH) {
|
||||
/* Received message too big, abort the operation. */
|
||||
result = -E2BIG;
|
||||
if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
|
||||
|
@ -684,16 +696,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
|
|||
goto continue_op;
|
||||
}
|
||||
|
||||
/* Remove the blocknum from the data. */
|
||||
len--;
|
||||
for (i = 0; i < len; i++)
|
||||
ssif_info->data[i + ssif_info->multi_len] = data[i + 1];
|
||||
ssif_info->data[i + ssif_info->multi_len] = data[i];
|
||||
ssif_info->multi_len += len;
|
||||
if (blocknum == 0xff) {
|
||||
/* End of read */
|
||||
len = ssif_info->multi_len;
|
||||
data = ssif_info->data;
|
||||
} else if (blocknum + 1 != ssif_info->multi_pos) {
|
||||
} else if (blocknum != ssif_info->multi_pos) {
|
||||
/*
|
||||
* Out of sequence block, just abort. Block
|
||||
* numbers start at zero for the second block,
|
||||
|
@ -721,6 +731,7 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
|
|||
}
|
||||
}
|
||||
|
||||
continue_op:
|
||||
if (result < 0) {
|
||||
ssif_inc_stat(ssif_info, receive_errors);
|
||||
} else {
|
||||
|
@ -728,8 +739,6 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
|
|||
ssif_inc_stat(ssif_info, received_message_parts);
|
||||
}
|
||||
|
||||
|
||||
continue_op:
|
||||
if (ssif_info->ssif_debug & SSIF_DEBUG_STATE)
|
||||
pr_info(PFX "DONE 1: state = %d, result=%d.\n",
|
||||
ssif_info->ssif_state, result);
|
||||
|
|
Loading…
Reference in a new issue