Skip to content

Commit

Permalink
ipmi: Fix sequence number handling
Browse files Browse the repository at this point in the history
The IPMI message handler uses a message id that the lower-layer
preserved to track the sequence number of the message.  The macros
that handled these sequence numbers were somewhat broken as they
could result in sequence number truncation and they were not
doing an "and" of the proper number of bits.

I think this actually is not a problem, because the truncation
should be harmless and the improper "and" didn't hurt anything
because sequence number generation used the same improper "and"
and wouldn't generate a sequence number that would get
truncated wrong.  However, it should be fixed.

Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Corey Minyard <[email protected]>
  • Loading branch information
cminyard committed Nov 25, 2016
1 parent 9467171 commit a24b5dd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/char/ipmi/ipmi_msghandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,16 @@ struct seq_table {
* Store the information in a msgid (long) to allow us to find a
* sequence table entry from the msgid.
*/
#define STORE_SEQ_IN_MSGID(seq, seqid) (((seq&0xff)<<26) | (seqid&0x3ffffff))
#define STORE_SEQ_IN_MSGID(seq, seqid) \
((((seq) & 0x3f) << 26) | ((seqid) & 0x3ffffff))

#define GET_SEQ_FROM_MSGID(msgid, seq, seqid) \
do { \
seq = ((msgid >> 26) & 0x3f); \
seqid = (msgid & 0x3fffff); \
seq = (((msgid) >> 26) & 0x3f); \
seqid = ((msgid) & 0x3ffffff); \
} while (0)

#define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3fffff)
#define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3ffffff)

struct ipmi_channel {
unsigned char medium;
Expand Down

0 comments on commit a24b5dd

Please sign in to comment.