Some small fixes for the IPMI driver

Nothing huge, some rate limiting on logs, a strncpy fix where the source
 and destination could be the same, and removal of some unused cruft.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE/Q1c5nzg9ZpmiCaGYfOMkJGb/4EFAmiTvX8ACgkQYfOMkJGb
 /4HUOBAAkHAytTqTsts+wCZmP5E7Omjg7dbxRpBrU/8n0wDy94JnM8ptMZZ9poUM
 KrALIod7429PJJCz+9/mMdnhqQoJV8SQUhk1pRd0pVPA5SJxN3wE4uPtG9HoZEDb
 3clr/K7xn96+MxyiitFqWAwNW6D6/S1VVcpiFWs3AuU9ghuoV/ytfkQYb1A8NrbX
 +Z54Rccqm7ZyuDtcLNkvlvhUKQMd/KjHeeH/uRepvc/586dEF+XLhJApqUT5ZWZF
 Xz8EoASkJq+PZCyiqXGK9yZhPR9bRu38ridxPHPOnbMNaF+4TAxt3I4SEeilCJGs
 ywcozsoa0phlub1VOENkmhLeWgQrSL+WY65wc0m132pkjWRFIP6OMtQaLnensd91
 PT++zRefU0AJ527j2D35B2bTkyYMKlkjR/eUtb9mF2+kA28+SExoNL2+p+hewNL2
 qEFBLUPkbYeN/m1xmJt9knOLEe41dEAGWbYvRJVtfSiatQ101MB/ixjASWRaRjYu
 M86MFgjb0TXmNeyvOkVC5V7GfHIuPMooKpPggqWjiWekyfpFnHCIj8eYSVYk/5ge
 Lm4yPTIJNgW374WX6Ou2ecJQg/NOlc016MUHkUdMUscoC33HUF8WL46DhKB4MiqR
 4vG+KrV5zkZNcc3rf9oVHwT3qGTtQMk9XprH/GESAx4ngXseMbg=
 =0zUC
 -----END PGP SIGNATURE-----

Merge tag 'for-linus-6.17-1' of https://github.com/cminyard/linux-ipmi

Pull ipmi updates from Corey Minyard:
 "Some small fixes for the IPMI driver

  Nothing huge, some rate limiting on logs, a strncpy fix where the
  source and destination could be the same, and removal of some unused
  cruft"

* tag 'for-linus-6.17-1' of https://github.com/cminyard/linux-ipmi:
  ipmi: Use dev_warn_ratelimited() for incorrect message warnings
  char: ipmi: remove redundant variable 'type' and check
  ipmi: Fix strcpy source and destination the same
This commit is contained in:
Linus Torvalds 2025-08-07 07:38:25 +03:00
commit d244f9bb59
3 changed files with 46 additions and 25 deletions

View file

@ -4607,10 +4607,10 @@ return_unspecified:
* The NetFN and Command in the response is not even
* marginally correct.
*/
dev_warn(intf->si_dev,
"BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n",
(msg->data[0] >> 2) | 1, msg->data[1],
msg->rsp[0] >> 2, msg->rsp[1]);
dev_warn_ratelimited(intf->si_dev,
"BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n",
(msg->data[0] >> 2) | 1, msg->data[1],
msg->rsp[0] >> 2, msg->rsp[1]);
goto return_unspecified;
}

View file

@ -2108,7 +2108,6 @@ static bool __init ipmi_smi_info_same(struct smi_info *e1, struct smi_info *e2)
static int __init init_ipmi_si(void)
{
struct smi_info *e, *e2;
enum ipmi_addr_src type = SI_INVALID;
if (initialized)
return 0;
@ -2190,9 +2189,6 @@ static int __init init_ipmi_si(void)
initialized = true;
mutex_unlock(&smi_infos_lock);
if (type)
return 0;
mutex_lock(&smi_infos_lock);
if (unload_when_empty && list_empty(&smi_infos)) {
mutex_unlock(&smi_infos_lock);

View file

@ -1146,14 +1146,8 @@ static struct ipmi_smi_watcher smi_watcher = {
.smi_gone = ipmi_smi_gone
};
static int action_op(const char *inval, char *outval)
static int action_op_set_val(const char *inval)
{
if (outval)
strcpy(outval, action);
if (!inval)
return 0;
if (strcmp(inval, "reset") == 0)
action_val = WDOG_TIMEOUT_RESET;
else if (strcmp(inval, "none") == 0)
@ -1164,18 +1158,26 @@ static int action_op(const char *inval, char *outval)
action_val = WDOG_TIMEOUT_POWER_DOWN;
else
return -EINVAL;
strcpy(action, inval);
return 0;
}
static int preaction_op(const char *inval, char *outval)
static int action_op(const char *inval, char *outval)
{
int rv;
if (outval)
strcpy(outval, preaction);
strcpy(outval, action);
if (!inval)
return 0;
rv = action_op_set_val(inval);
if (!rv)
strcpy(action, inval);
return rv;
}
static int preaction_op_set_val(const char *inval)
{
if (strcmp(inval, "pre_none") == 0)
preaction_val = WDOG_PRETIMEOUT_NONE;
else if (strcmp(inval, "pre_smi") == 0)
@ -1188,18 +1190,26 @@ static int preaction_op(const char *inval, char *outval)
preaction_val = WDOG_PRETIMEOUT_MSG_INT;
else
return -EINVAL;
strcpy(preaction, inval);
return 0;
}
static int preop_op(const char *inval, char *outval)
static int preaction_op(const char *inval, char *outval)
{
int rv;
if (outval)
strcpy(outval, preop);
strcpy(outval, preaction);
if (!inval)
return 0;
rv = preaction_op_set_val(inval);
if (!rv)
strcpy(preaction, inval);
return 0;
}
static int preop_op_set_val(const char *inval)
{
if (strcmp(inval, "preop_none") == 0)
preop_val = WDOG_PREOP_NONE;
else if (strcmp(inval, "preop_panic") == 0)
@ -1208,7 +1218,22 @@ static int preop_op(const char *inval, char *outval)
preop_val = WDOG_PREOP_GIVE_DATA;
else
return -EINVAL;
strcpy(preop, inval);
return 0;
}
static int preop_op(const char *inval, char *outval)
{
int rv;
if (outval)
strcpy(outval, preop);
if (!inval)
return 0;
rv = preop_op_set_val(inval);
if (!rv)
strcpy(preop, inval);
return 0;
}
@ -1245,18 +1270,18 @@ static int __init ipmi_wdog_init(void)
{
int rv;
if (action_op(action, NULL)) {
if (action_op_set_val(action)) {
action_op("reset", NULL);
pr_info("Unknown action '%s', defaulting to reset\n", action);
}
if (preaction_op(preaction, NULL)) {
if (preaction_op_set_val(preaction)) {
preaction_op("pre_none", NULL);
pr_info("Unknown preaction '%s', defaulting to none\n",
preaction);
}
if (preop_op(preop, NULL)) {
if (preop_op_set_val(preop)) {
preop_op("preop_none", NULL);
pr_info("Unknown preop '%s', defaulting to none\n", preop);
}