Skip to content

Commit ed59cd2

Browse files
committed
ipmi:msghandler: Add a error return from unhandle LAN cmds
If we get a command from a LAN channel, return an error instead of just throwing it away. Signed-off-by: Corey Minyard <cminyard@mvista.com>
1 parent 8871e77 commit ed59cd2

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4165,14 +4165,33 @@ static int handle_lan_get_msg_cmd(struct ipmi_smi *intf,
41654165
rcu_read_unlock();
41664166

41674167
if (user == NULL) {
4168-
/* We didn't find a user, just give up. */
4168+
/* We didn't find a user, just give up and return an error. */
41694169
ipmi_inc_stat(intf, unhandled_commands);
41704170

4171+
msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2);
4172+
msg->data[1] = IPMI_SEND_MSG_CMD;
4173+
msg->data[2] = chan;
4174+
msg->data[3] = msg->rsp[4]; /* handle */
4175+
msg->data[4] = msg->rsp[8]; /* rsSWID */
4176+
msg->data[5] = ((netfn + 1) << 2) | (msg->rsp[9] & 0x3);
4177+
msg->data[6] = ipmb_checksum(&msg->data[3], 3);
4178+
msg->data[7] = msg->rsp[5]; /* rqSWID */
4179+
/* rqseq/lun */
4180+
msg->data[8] = (msg->rsp[9] & 0xfc) | (msg->rsp[6] & 0x3);
4181+
msg->data[9] = cmd;
4182+
msg->data[10] = IPMI_INVALID_CMD_COMPLETION_CODE;
4183+
msg->data[11] = ipmb_checksum(&msg->data[7], 4);
4184+
msg->data_size = 12;
4185+
4186+
dev_dbg(intf->si_dev, "Invalid command: %*ph\n",
4187+
msg->data_size, msg->data);
4188+
4189+
smi_send(intf, intf->handlers, msg, 0);
41714190
/*
4172-
* Don't do anything with these messages, just allow
4173-
* them to be freed.
4191+
* We used the message, so return the value that
4192+
* causes it to not be freed or queued.
41744193
*/
4175-
rv = 0;
4194+
rv = -1;
41764195
} else {
41774196
recv_msg = ipmi_alloc_recv_msg();
41784197
if (!recv_msg) {

0 commit comments

Comments
 (0)