Skip to content

Commit 4ecf752

Browse files
cminyardgregkh
authored andcommitted
ipmi: fix unsigned long underflow
commit 392a17b10ec4320d3c0e96e2a23ebaad1123b989 upstream. When I set the timeout to a specific value such as 500ms, the timeout event will not happen in time due to the overflow in function check_msg_timeout: ... ent->timeout -= timeout_period; if (ent->timeout > 0) return; ... The type of timeout_period is long, but ent->timeout is unsigned long. This patch makes the type consistent. Reported-by: Weilong Chen <chenweilong@huawei.com> Signed-off-by: Corey Minyard <cminyard@mvista.com> Tested-by: Weilong Chen <chenweilong@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c4baa4a commit 4ecf752

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,7 +4029,8 @@ smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
40294029
}
40304030

40314031
static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
4032-
struct list_head *timeouts, long timeout_period,
4032+
struct list_head *timeouts,
4033+
unsigned long timeout_period,
40334034
int slot, unsigned long *flags,
40344035
unsigned int *waiting_msgs)
40354036
{
@@ -4042,8 +4043,8 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
40424043
if (!ent->inuse)
40434044
return;
40444045

4045-
ent->timeout -= timeout_period;
4046-
if (ent->timeout > 0) {
4046+
if (timeout_period < ent->timeout) {
4047+
ent->timeout -= timeout_period;
40474048
(*waiting_msgs)++;
40484049
return;
40494050
}
@@ -4109,7 +4110,8 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
41094110
}
41104111
}
41114112

4112-
static unsigned int ipmi_timeout_handler(ipmi_smi_t intf, long timeout_period)
4113+
static unsigned int ipmi_timeout_handler(ipmi_smi_t intf,
4114+
unsigned long timeout_period)
41134115
{
41144116
struct list_head timeouts;
41154117
struct ipmi_recv_msg *msg, *msg2;

0 commit comments

Comments
 (0)