Skip to content

Commit 43247ab

Browse files
qzhuo2aegl
authored andcommitted
EDAC/sb_edac: Fix the compile warning of large frame size
Compiling sb_edac driver with GCC 11.4.0 and the W=1 option reported the following warning: drivers/edac/sb_edac.c: In function ‘sbridge_mce_output_error’: drivers/edac/sb_edac.c:3249:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=] As there is no concurrent invocation of sbridge_mce_output_error(), fix this warning by moving the large-size variables 'msg' and 'msg_full' from the stack to the pre-allocated data segment. [Tony: Fix checkpatch warnings for code alignment & use of strcpy()] Reported-by: Zhang Rui <[email protected]> Tested-by: Zhang Rui <[email protected]> Signed-off-by: Qiuxu Zhuo <[email protected]> Signed-off-by: Tony Luck <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 7a33c14 commit 43247ab

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

drivers/edac/sb_edac.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
/* Static vars */
3131
static LIST_HEAD(sbridge_edac_list);
32+
static char sb_msg[256];
33+
static char sb_msg_full[512];
3234

3335
/*
3436
* Alter this version for the module when modifications are made
@@ -3079,7 +3081,6 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci,
30793081
struct mem_ctl_info *new_mci;
30803082
struct sbridge_pvt *pvt = mci->pvt_info;
30813083
enum hw_event_mc_err_type tp_event;
3082-
char *optype, msg[256], msg_full[512];
30833084
bool ripv = GET_BITFIELD(m->mcgstatus, 0, 0);
30843085
bool overflow = GET_BITFIELD(m->status, 62, 62);
30853086
bool uncorrected_error = GET_BITFIELD(m->status, 61, 61);
@@ -3095,10 +3096,10 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci,
30953096
* aligned address reported by patrol scrubber.
30963097
*/
30973098
u32 lsb = GET_BITFIELD(m->misc, 0, 5);
3099+
char *optype, *area_type = "DRAM";
30983100
long channel_mask, first_channel;
30993101
u8 rank = 0xff, socket, ha;
31003102
int rc, dimm;
3101-
char *area_type = "DRAM";
31023103

31033104
if (pvt->info.type != SANDY_BRIDGE)
31043105
recoverable = true;
@@ -3168,32 +3169,32 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci,
31683169
channel = knl_channel_remap(m->bank == 16, channel);
31693170
channel_mask = 1 << channel;
31703171

3171-
snprintf(msg, sizeof(msg),
3172-
"%s%s err_code:%04x:%04x channel:%d (DIMM_%c)",
3173-
overflow ? " OVERFLOW" : "",
3174-
(uncorrected_error && recoverable)
3175-
? " recoverable" : " ",
3176-
mscod, errcode, channel, A + channel);
3172+
snprintf(sb_msg, sizeof(sb_msg),
3173+
"%s%s err_code:%04x:%04x channel:%d (DIMM_%c)",
3174+
overflow ? " OVERFLOW" : "",
3175+
(uncorrected_error && recoverable)
3176+
? " recoverable" : " ",
3177+
mscod, errcode, channel, A + channel);
31773178
edac_mc_handle_error(tp_event, mci, core_err_cnt,
31783179
m->addr >> PAGE_SHIFT, m->addr & ~PAGE_MASK, 0,
31793180
channel, 0, -1,
3180-
optype, msg);
3181+
optype, sb_msg);
31813182
}
31823183
return;
31833184
} else if (lsb < 12) {
31843185
rc = get_memory_error_data(mci, m->addr, &socket, &ha,
31853186
&channel_mask, &rank,
3186-
&area_type, msg);
3187+
&area_type, sb_msg);
31873188
} else {
31883189
rc = get_memory_error_data_from_mce(mci, m, &socket, &ha,
3189-
&channel_mask, msg);
3190+
&channel_mask, sb_msg);
31903191
}
31913192

31923193
if (rc < 0)
31933194
goto err_parsing;
31943195
new_mci = get_mci_for_node_id(socket, ha);
31953196
if (!new_mci) {
3196-
strcpy(msg, "Error: socket got corrupted!");
3197+
strscpy(sb_msg, "Error: socket got corrupted!");
31973198
goto err_parsing;
31983199
}
31993200
mci = new_mci;
@@ -3218,17 +3219,17 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci,
32183219
*/
32193220
if (!pvt->is_lockstep && !pvt->is_cur_addr_mirrored && !pvt->is_close_pg)
32203221
channel = first_channel;
3221-
snprintf(msg_full, sizeof(msg_full),
3222+
snprintf(sb_msg_full, sizeof(sb_msg_full),
32223223
"%s%s area:%s err_code:%04x:%04x socket:%d ha:%d channel_mask:%ld rank:%d %s",
32233224
overflow ? " OVERFLOW" : "",
32243225
(uncorrected_error && recoverable) ? " recoverable" : "",
32253226
area_type,
32263227
mscod, errcode,
32273228
socket, ha,
32283229
channel_mask,
3229-
rank, msg);
3230+
rank, sb_msg);
32303231

3231-
edac_dbg(0, "%s\n", msg_full);
3232+
edac_dbg(0, "%s\n", sb_msg_full);
32323233

32333234
/* FIXME: need support for channel mask */
32343235

@@ -3239,12 +3240,12 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci,
32393240
edac_mc_handle_error(tp_event, mci, core_err_cnt,
32403241
m->addr >> PAGE_SHIFT, m->addr & ~PAGE_MASK, 0,
32413242
channel, dimm, -1,
3242-
optype, msg_full);
3243+
optype, sb_msg_full);
32433244
return;
32443245
err_parsing:
32453246
edac_mc_handle_error(tp_event, mci, core_err_cnt, 0, 0, 0,
32463247
-1, -1, -1,
3247-
msg, "");
3248+
sb_msg, "");
32483249

32493250
}
32503251

0 commit comments

Comments
 (0)