Skip to content

Commit

Permalink
Merge branch 'ipmi' (minor ipmi fixes from Corey)
Browse files Browse the repository at this point in the history
Merge ipmi fixes from Corey Minyard:
 "Some minor fixes I had queued up.  The last one came in recently
  (patch 4) and it and patch 2 are candidates for stable-kernel."

* emailed patches from Corey Minyard <cminyard@mvista.com>:
  ipmi: ipmi_devintf: compat_ioctl method fails to take ipmi_mutex
  ipmi: Improve error messages on failed irq enable
  drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory overflow
  drivers: char: ipmi: Replaced kmalloc and strcpy with kstrdup
  • Loading branch information
Linus Torvalds committed May 16, 2013
2 parents 4a007ed + 6368087 commit e2a978e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions drivers/char/ipmi/ipmi_bt_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ struct si_sm_data {
enum bt_states state;
unsigned char seq; /* BT sequence number */
struct si_sm_io *io;
unsigned char write_data[IPMI_MAX_MSG_LENGTH];
unsigned char write_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
int write_count;
unsigned char read_data[IPMI_MAX_MSG_LENGTH];
unsigned char read_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
int read_count;
int truncated;
long timeout; /* microseconds countdown */
Expand Down
14 changes: 13 additions & 1 deletion drivers/char/ipmi/ipmi_devintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,13 +837,25 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
return ipmi_ioctl(filep, cmd, arg);
}
}

static long unlocked_compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
unsigned long arg)
{
int ret;

mutex_lock(&ipmi_mutex);
ret = compat_ipmi_ioctl(filep, cmd, arg);
mutex_unlock(&ipmi_mutex);

return ret;
}
#endif

static const struct file_operations ipmi_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = ipmi_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_ipmi_ioctl,
.compat_ioctl = unlocked_compat_ipmi_ioctl,
#endif
.open = ipmi_open,
.release = ipmi_release,
Expand Down
3 changes: 1 addition & 2 deletions drivers/char/ipmi/ipmi_msghandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2037,12 +2037,11 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (!entry)
return -ENOMEM;
entry->name = kmalloc(strlen(name)+1, GFP_KERNEL);
entry->name = kstrdup(name, GFP_KERNEL);
if (!entry->name) {
kfree(entry);
return -ENOMEM;
}
strcpy(entry->name, name);

file = proc_create_data(name, 0, smi->proc_dir, proc_ops, data);
if (!file) {
Expand Down
16 changes: 10 additions & 6 deletions drivers/char/ipmi/ipmi_si_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,10 @@ static void handle_transaction_done(struct smi_info *smi_info)
/* We got the flags from the SMI, now handle them. */
smi_info->handlers->get_result(smi_info->si_sm, msg, 4);
if (msg[2] != 0) {
dev_warn(smi_info->dev, "Could not enable interrupts"
", failed get, using polled mode.\n");
dev_warn(smi_info->dev,
"Couldn't get irq info: %x.\n", msg[2]);
dev_warn(smi_info->dev,
"Maybe ok, but ipmi might run very slowly.\n");
smi_info->si_state = SI_NORMAL;
} else {
msg[0] = (IPMI_NETFN_APP_REQUEST << 2);
Expand All @@ -685,10 +687,12 @@ static void handle_transaction_done(struct smi_info *smi_info)

/* We got the flags from the SMI, now handle them. */
smi_info->handlers->get_result(smi_info->si_sm, msg, 4);
if (msg[2] != 0)
dev_warn(smi_info->dev, "Could not enable interrupts"
", failed set, using polled mode.\n");
else
if (msg[2] != 0) {
dev_warn(smi_info->dev,
"Couldn't set irq info: %x.\n", msg[2]);
dev_warn(smi_info->dev,
"Maybe ok, but ipmi might run very slowly.\n");
} else
smi_info->interrupt_disabled = 0;
smi_info->si_state = SI_NORMAL;
break;
Expand Down

0 comments on commit e2a978e

Please sign in to comment.