aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-09-09 18:38:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-10 16:29:01 -0400
commit6fc37c4900765d579f25fbd293fcda7be5037896 (patch)
tree6af4b3496d06edc2c3b4d26bb3ad8c59a9af0781 /mm
parent5d2fe875c9e822aa55579ea2032153e2891db57a (diff)
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>
Diffstat (limited to 'mm')
-rw-r--r--mm/kmemleak.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index f532f6a37b55..77191eccdc6f 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -302,23 +302,14 @@ static void hex_dump_object(struct seq_file *seq,
302 struct kmemleak_object *object) 302 struct kmemleak_object *object)
303{ 303{
304 const u8 *ptr = (const u8 *)object->pointer; 304 const u8 *ptr = (const u8 *)object->pointer;
305 int i, len, remaining; 305 size_t len;
306 unsigned char linebuf[HEX_ROW_SIZE * 5];
307 306
308 /* limit the number of lines to HEX_MAX_LINES */ 307 /* limit the number of lines to HEX_MAX_LINES */
309 remaining = len = 308 len = min_t(size_t, object->size, HEX_MAX_LINES * HEX_ROW_SIZE);
310 min(object->size, (size_t)(HEX_MAX_LINES * HEX_ROW_SIZE)); 309
311 310 seq_printf(seq, " hex dump (first %zu bytes):\n", len);
312 seq_printf(seq, " hex dump (first %d bytes):\n", len); 311 seq_hex_dump(seq, " ", DUMP_PREFIX_NONE, HEX_ROW_SIZE,
313 for (i = 0; i < len; i += HEX_ROW_SIZE) { 312 HEX_GROUP_SIZE, ptr, len, HEX_ASCII);
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 }
322} 313}
323 314
324/* 315/*