Skip to content

Commit 6fc37c4

Browse files
andy-shevtorvalds
authored andcommitted
kmemleak: use seq_hex_dump() to dump buffers
Instead of custom approach let's use recently introduced seq_hex_dump() helper. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Joe Perches <joe@perches.com> Cc: Tadeusz Struk <tadeusz.struk@intel.com> Cc: Helge Deller <deller@gmx.de> Cc: Ingo Tuchscherer <ingo.tuchscherer@de.ibm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5d2fe87 commit 6fc37c4

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

mm/kmemleak.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -302,23 +302,14 @@ static void hex_dump_object(struct seq_file *seq,
302302
struct kmemleak_object *object)
303303
{
304304
const u8 *ptr = (const u8 *)object->pointer;
305-
int i, len, remaining;
306-
unsigned char linebuf[HEX_ROW_SIZE * 5];
305+
size_t len;
307306

308307
/* limit the number of lines to HEX_MAX_LINES */
309-
remaining = len =
310-
min(object->size, (size_t)(HEX_MAX_LINES * HEX_ROW_SIZE));
311-
312-
seq_printf(seq, " hex dump (first %d bytes):\n", len);
313-
for (i = 0; i < len; i += HEX_ROW_SIZE) {
314-
int linelen = min(remaining, HEX_ROW_SIZE);
315-
316-
remaining -= HEX_ROW_SIZE;
317-
hex_dump_to_buffer(ptr + i, linelen, HEX_ROW_SIZE,
318-
HEX_GROUP_SIZE, linebuf, sizeof(linebuf),
319-
HEX_ASCII);
320-
seq_printf(seq, " %s\n", linebuf);
321-
}
308+
len = min_t(size_t, object->size, HEX_MAX_LINES * HEX_ROW_SIZE);
309+
310+
seq_printf(seq, " hex dump (first %zu bytes):\n", len);
311+
seq_hex_dump(seq, " ", DUMP_PREFIX_NONE, HEX_ROW_SIZE,
312+
HEX_GROUP_SIZE, ptr, len, HEX_ASCII);
322313
}
323314

324315
/*

0 commit comments

Comments
 (0)