Skip to content

Commit

Permalink
ghes_edac: Use snprintf() to silence a static checker warning
Browse files Browse the repository at this point in the history
My static checker complains because the "e->location" has up to 256
characters but we are copying it into the "pvt->detail_location" which
only has space for 240 characters.  That's not counting the surrounding
text and the "e->other_detail" string which can be over 80 characters
long.

I am not familiar with this code but presumably it normally works.
Let's add a limit though for safety.

Signed-off-by: Dan Carpenter <[email protected]>
Acked-by: Mauro Carvalho Chehab <[email protected]>
Link: http://lkml.kernel.org/r/20140801082514.GD28869@mwanda
Signed-off-by: Borislav Petkov <[email protected]>
  • Loading branch information
Dan Carpenter authored and suryasaimadhu committed Nov 11, 2014
1 parent f5b10c4 commit 665aa8c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/edac/ghes_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev,

/* Generate the trace event */
grain_bits = fls_long(e->grain);
sprintf(pvt->detail_location, "APEI location: %s %s",
e->location, e->other_detail);
snprintf(pvt->detail_location, sizeof(pvt->detail_location),
"APEI location: %s %s", e->location, e->other_detail);
trace_mc_event(type, e->msg, e->label, e->error_count,
mci->mc_idx, e->top_layer, e->mid_layer, e->low_layer,
PAGES_TO_MiB(e->page_frame_number) | e->offset_in_page,
Expand Down

0 comments on commit 665aa8c

Please sign in to comment.