Skip to content

Commit

Permalink
[PATCH] IPMI: fix issues reported by Coverity in ipmi_msghandler.c
Browse files Browse the repository at this point in the history
While looking to the report by Coverity in ipmi, I came across the
following issue:

The IPMI message handler relies on two defines which are the same -one in
include/linux/ipmi.h
#define IPMI_NUM_CHANNELS 0x10
and one in drivers/char/ipmi/ipmi_msghandler.
#define IPMI_MAX_CHANNELS       16
These are used interchangeably in ipmi_msghandler.c, but since the array
addr->channels[] is of size IPMI_MAX_CHANNELS, I have made a patch that
uses IPMI_MAX_CHANNELS for all the checks for the array index.

NOTE: You could probably remove the line that defines IPMI_NUM_CHANNELS
from ipmi.h, or move IPMI_MAX_CHANNELS to ipmi.h

Signed-off-by: Jayachandran C. <c.jayachandran@gmail.com>
Cc: Corey Minyard <minyard@acm.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Jayachandran C authored and Linus Torvalds committed Feb 3, 2006
1 parent db9a369 commit 12fc1d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/char/ipmi/ipmi_msghandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ int ipmi_validate_addr(struct ipmi_addr *addr, int len)
}

if ((addr->channel == IPMI_BMC_CHANNEL)
|| (addr->channel >= IPMI_NUM_CHANNELS)
|| (addr->channel >= IPMI_MAX_CHANNELS)
|| (addr->channel < 0))
return -EINVAL;

Expand Down Expand Up @@ -1321,7 +1321,7 @@ static int i_ipmi_request(ipmi_user_t user,
unsigned char ipmb_seq;
long seqid;

if (addr->channel >= IPMI_NUM_CHANNELS) {
if (addr->channel >= IPMI_MAX_CHANNELS) {
spin_lock_irqsave(&intf->counter_lock, flags);
intf->sent_invalid_commands++;
spin_unlock_irqrestore(&intf->counter_lock, flags);
Expand Down

0 comments on commit 12fc1d7

Please sign in to comment.