diff options
| -rw-r--r-- | lib/vsprintf.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 87dbced51b1a..9004bbb3d84d 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -1367,13 +1367,6 @@ static noinline_for_stack | |||
| 1367 | char *restricted_pointer(char *buf, char *end, const void *ptr, | 1367 | char *restricted_pointer(char *buf, char *end, const void *ptr, |
| 1368 | struct printf_spec spec) | 1368 | struct printf_spec spec) |
| 1369 | { | 1369 | { |
| 1370 | spec.base = 16; | ||
| 1371 | spec.flags |= SMALL; | ||
| 1372 | if (spec.field_width == -1) { | ||
| 1373 | spec.field_width = 2 * sizeof(ptr); | ||
| 1374 | spec.flags |= ZEROPAD; | ||
| 1375 | } | ||
| 1376 | |||
| 1377 | switch (kptr_restrict) { | 1370 | switch (kptr_restrict) { |
| 1378 | case 0: | 1371 | case 0: |
| 1379 | /* Always print %pK values */ | 1372 | /* Always print %pK values */ |
| @@ -1385,8 +1378,11 @@ char *restricted_pointer(char *buf, char *end, const void *ptr, | |||
| 1385 | * kptr_restrict==1 cannot be used in IRQ context | 1378 | * kptr_restrict==1 cannot be used in IRQ context |
| 1386 | * because its test for CAP_SYSLOG would be meaningless. | 1379 | * because its test for CAP_SYSLOG would be meaningless. |
| 1387 | */ | 1380 | */ |
| 1388 | if (in_irq() || in_serving_softirq() || in_nmi()) | 1381 | if (in_irq() || in_serving_softirq() || in_nmi()) { |
| 1382 | if (spec.field_width == -1) | ||
| 1383 | spec.field_width = 2 * sizeof(ptr); | ||
| 1389 | return string(buf, end, "pK-error", spec); | 1384 | return string(buf, end, "pK-error", spec); |
| 1385 | } | ||
| 1390 | 1386 | ||
| 1391 | /* | 1387 | /* |
| 1392 | * Only print the real pointer value if the current | 1388 | * Only print the real pointer value if the current |
| @@ -1411,7 +1407,7 @@ char *restricted_pointer(char *buf, char *end, const void *ptr, | |||
| 1411 | break; | 1407 | break; |
| 1412 | } | 1408 | } |
| 1413 | 1409 | ||
| 1414 | return number(buf, end, (unsigned long)ptr, spec); | 1410 | return pointer_string(buf, end, ptr, spec); |
| 1415 | } | 1411 | } |
| 1416 | 1412 | ||
| 1417 | static noinline_for_stack | 1413 | static noinline_for_stack |
| @@ -1686,10 +1682,9 @@ early_initcall(initialize_ptr_random); | |||
| 1686 | static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) | 1682 | static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) |
| 1687 | { | 1683 | { |
| 1688 | unsigned long hashval; | 1684 | unsigned long hashval; |
| 1689 | const int default_width = 2 * sizeof(ptr); | ||
| 1690 | 1685 | ||
| 1691 | if (unlikely(!have_filled_random_ptr_key)) { | 1686 | if (unlikely(!have_filled_random_ptr_key)) { |
| 1692 | spec.field_width = default_width; | 1687 | spec.field_width = 2 * sizeof(ptr); |
| 1693 | /* string length must be less than default_width */ | 1688 | /* string length must be less than default_width */ |
| 1694 | return string(buf, end, "(ptrval)", spec); | 1689 | return string(buf, end, "(ptrval)", spec); |
| 1695 | } | 1690 | } |
| @@ -1704,15 +1699,7 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) | |||
| 1704 | #else | 1699 | #else |
| 1705 | hashval = (unsigned long)siphash_1u32((u32)ptr, &ptr_key); | 1700 | hashval = (unsigned long)siphash_1u32((u32)ptr, &ptr_key); |
| 1706 | #endif | 1701 | #endif |
| 1707 | 1702 | return pointer_string(buf, end, (const void *)hashval, spec); | |
| 1708 | spec.flags |= SMALL; | ||
| 1709 | if (spec.field_width == -1) { | ||
| 1710 | spec.field_width = default_width; | ||
| 1711 | spec.flags |= ZEROPAD; | ||
| 1712 | } | ||
| 1713 | spec.base = 16; | ||
| 1714 | |||
| 1715 | return number(buf, end, hashval, spec); | ||
| 1716 | } | 1703 | } |
| 1717 | 1704 | ||
| 1718 | /* | 1705 | /* |
