Skip to content

Commit d244f9b

Browse files
committed
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
2 parents 2095cf5 + ec50ec3 commit d244f9b

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4607,10 +4607,10 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,
46074607
* The NetFN and Command in the response is not even
46084608
* marginally correct.
46094609
*/
4610-
dev_warn(intf->si_dev,
4611-
"BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n",
4612-
(msg->data[0] >> 2) | 1, msg->data[1],
4613-
msg->rsp[0] >> 2, msg->rsp[1]);
4610+
dev_warn_ratelimited(intf->si_dev,
4611+
"BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n",
4612+
(msg->data[0] >> 2) | 1, msg->data[1],
4613+
msg->rsp[0] >> 2, msg->rsp[1]);
46144614

46154615
goto return_unspecified;
46164616
}

drivers/char/ipmi/ipmi_si_intf.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,7 +2108,6 @@ static bool __init ipmi_smi_info_same(struct smi_info *e1, struct smi_info *e2)
21082108
static int __init init_ipmi_si(void)
21092109
{
21102110
struct smi_info *e, *e2;
2111-
enum ipmi_addr_src type = SI_INVALID;
21122111

21132112
if (initialized)
21142113
return 0;
@@ -2190,9 +2189,6 @@ static int __init init_ipmi_si(void)
21902189
initialized = true;
21912190
mutex_unlock(&smi_infos_lock);
21922191

2193-
if (type)
2194-
return 0;
2195-
21962192
mutex_lock(&smi_infos_lock);
21972193
if (unload_when_empty && list_empty(&smi_infos)) {
21982194
mutex_unlock(&smi_infos_lock);

drivers/char/ipmi/ipmi_watchdog.c

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,14 +1146,8 @@ static struct ipmi_smi_watcher smi_watcher = {
11461146
.smi_gone = ipmi_smi_gone
11471147
};
11481148

1149-
static int action_op(const char *inval, char *outval)
1149+
static int action_op_set_val(const char *inval)
11501150
{
1151-
if (outval)
1152-
strcpy(outval, action);
1153-
1154-
if (!inval)
1155-
return 0;
1156-
11571151
if (strcmp(inval, "reset") == 0)
11581152
action_val = WDOG_TIMEOUT_RESET;
11591153
else if (strcmp(inval, "none") == 0)
@@ -1164,18 +1158,26 @@ static int action_op(const char *inval, char *outval)
11641158
action_val = WDOG_TIMEOUT_POWER_DOWN;
11651159
else
11661160
return -EINVAL;
1167-
strcpy(action, inval);
11681161
return 0;
11691162
}
11701163

1171-
static int preaction_op(const char *inval, char *outval)
1164+
static int action_op(const char *inval, char *outval)
11721165
{
1166+
int rv;
1167+
11731168
if (outval)
1174-
strcpy(outval, preaction);
1169+
strcpy(outval, action);
11751170

11761171
if (!inval)
11771172
return 0;
1173+
rv = action_op_set_val(inval);
1174+
if (!rv)
1175+
strcpy(action, inval);
1176+
return rv;
1177+
}
11781178

1179+
static int preaction_op_set_val(const char *inval)
1180+
{
11791181
if (strcmp(inval, "pre_none") == 0)
11801182
preaction_val = WDOG_PRETIMEOUT_NONE;
11811183
else if (strcmp(inval, "pre_smi") == 0)
@@ -1188,18 +1190,26 @@ static int preaction_op(const char *inval, char *outval)
11881190
preaction_val = WDOG_PRETIMEOUT_MSG_INT;
11891191
else
11901192
return -EINVAL;
1191-
strcpy(preaction, inval);
11921193
return 0;
11931194
}
11941195

1195-
static int preop_op(const char *inval, char *outval)
1196+
static int preaction_op(const char *inval, char *outval)
11961197
{
1198+
int rv;
1199+
11971200
if (outval)
1198-
strcpy(outval, preop);
1201+
strcpy(outval, preaction);
11991202

12001203
if (!inval)
12011204
return 0;
1205+
rv = preaction_op_set_val(inval);
1206+
if (!rv)
1207+
strcpy(preaction, inval);
1208+
return 0;
1209+
}
12021210

1211+
static int preop_op_set_val(const char *inval)
1212+
{
12031213
if (strcmp(inval, "preop_none") == 0)
12041214
preop_val = WDOG_PREOP_NONE;
12051215
else if (strcmp(inval, "preop_panic") == 0)
@@ -1208,7 +1218,22 @@ static int preop_op(const char *inval, char *outval)
12081218
preop_val = WDOG_PREOP_GIVE_DATA;
12091219
else
12101220
return -EINVAL;
1211-
strcpy(preop, inval);
1221+
return 0;
1222+
}
1223+
1224+
static int preop_op(const char *inval, char *outval)
1225+
{
1226+
int rv;
1227+
1228+
if (outval)
1229+
strcpy(outval, preop);
1230+
1231+
if (!inval)
1232+
return 0;
1233+
1234+
rv = preop_op_set_val(inval);
1235+
if (!rv)
1236+
strcpy(preop, inval);
12121237
return 0;
12131238
}
12141239

@@ -1245,18 +1270,18 @@ static int __init ipmi_wdog_init(void)
12451270
{
12461271
int rv;
12471272

1248-
if (action_op(action, NULL)) {
1273+
if (action_op_set_val(action)) {
12491274
action_op("reset", NULL);
12501275
pr_info("Unknown action '%s', defaulting to reset\n", action);
12511276
}
12521277

1253-
if (preaction_op(preaction, NULL)) {
1278+
if (preaction_op_set_val(preaction)) {
12541279
preaction_op("pre_none", NULL);
12551280
pr_info("Unknown preaction '%s', defaulting to none\n",
12561281
preaction);
12571282
}
12581283

1259-
if (preop_op(preop, NULL)) {
1284+
if (preop_op_set_val(preop)) {
12601285
preop_op("preop_none", NULL);
12611286
pr_info("Unknown preop '%s', defaulting to none\n", preop);
12621287
}

0 commit comments

Comments
 (0)