return widen_string(buf, len, end, spec);
}
+/* Be careful: error messages must fit into the given buffer. */
+static char *error_string(char *buf, char *end, const char *s,
+ struct printf_spec spec)
+{
+ /*
+ * Hard limit to avoid a completely insane messages. It actually
+ * works pretty well because most error messages are in
+ * the many pointer format modifiers.
+ */
+ if (spec.precision == -1)
+ spec.precision = 2 * sizeof(void *);
+
+ return string_nocheck(buf, end, s, spec);
+}
+
/*
* This is not a fool-proof test. 99% of the time that this will fault is
* due to a bad pointer, not one that crosses into bad memory. Just test
err_msg = check_pointer_msg(ptr);
if (err_msg) {
- *buf = string_nocheck(*buf, end, err_msg, spec);
+ *buf = error_string(*buf, end, err_msg, spec);
return -EFAULT;
}
if (static_branch_unlikely(¬_filled_random_ptr_key)) {
spec.field_width = 2 * sizeof(ptr);
/* string length must be less than default_width */
- return string_nocheck(buf, end, str, spec);
+ return error_string(buf, end, str, spec);
}
#ifdef CONFIG_64BIT
if (in_irq() || in_serving_softirq() || in_nmi()) {
if (spec.field_width == -1)
spec.field_width = 2 * sizeof(ptr);
- return string_nocheck(buf, end, "pK-error", spec);
+ return error_string(buf, end, "pK-error", spec);
}
/*
case AF_INET6:
return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt);
default:
- return string_nocheck(buf, end, "(einval)", spec);
+ return error_string(buf, end, "(einval)", spec);
}}
}
err_fmt_msg = fmt[0] == 'i' ? "(%pi?)" : "(%pI?)";
- return string_nocheck(buf, end, err_fmt_msg, spec);
+ return error_string(buf, end, err_fmt_msg, spec);
}
static noinline_for_stack
size = sizeof(netdev_features_t);
break;
default:
- return string_nocheck(buf, end, "(%pN?)", spec);
+ return error_string(buf, end, "(%pN?)", spec);
}
return special_hex_number(buf, end, num, size);
case 'R':
return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt);
default:
- return string_nocheck(buf, end, "(%ptR?)", spec);
+ return error_string(buf, end, "(%ptR?)", spec);
}
}
const char *fmt)
{
if (!IS_ENABLED(CONFIG_HAVE_CLK))
- return string_nocheck(buf, end, "(%pC?)", spec);
+ return error_string(buf, end, "(%pC?)", spec);
if (check_pointer(&buf, end, clk, spec))
return buf;
#ifdef CONFIG_COMMON_CLK
return string(buf, end, __clk_get_name(clk), spec);
#else
- return string_nocheck(buf, end, "(%pC?)", spec);
+ return error_string(buf, end, "(%pC?)", spec);
#endif
}
}
names = gfpflag_names;
break;
default:
- return string_nocheck(buf, end, "(%pG?)", spec);
+ return error_string(buf, end, "(%pG?)", spec);
}
return format_flags(buf, end, flags, names);
str_spec.field_width = -1;
if (!IS_ENABLED(CONFIG_OF))
- return string_nocheck(buf, end, "(%pOF?)", spec);
+ return error_string(buf, end, "(%pOF?)", spec);
if (check_pointer(&buf, end, dn, spec))
return buf;
return device_node_string(buf, end, ptr, spec, fmt + 1);
}
- return string_nocheck(buf, end, "(%pO?)", spec);
+ return error_string(buf, end, "(%pO?)", spec);
}
/*