Add noinline_for_stack to function.
Make pointer argument the actual type.
Check pointer for NULL and use 0 when so.
Signed-off-by: Joe Perches <j...@perches.com>
---
lib/vsprintf.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 8e75003..0f1dfd9 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -777,16 +777,24 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
return string(buf, end, uuid, spec);
}
-static
-char *netdev_feature_string(char *buf, char *end, const u8 *addr,
- struct printf_spec spec)
+static noinline_for_stack
+char *netdev_feature_string(char *buf, char *end,
+ const netdev_features_t *features,
+ struct printf_spec spec)
{
+ unsigned long long num;
+
+ if (features)
+ num = (unsigned long long)*features;
+ else
+ num = 0;
+
spec.flags |= SPECIAL | SMALL | ZEROPAD;
if (spec.field_width == -1)
spec.field_width = 2 + 2 * sizeof(netdev_features_t);
spec.base = 16;
- return number(buf, end, *(const netdev_features_t *)addr, spec);
+ return number(buf, end, num, spec);
}
int kptr_restrict __read_mostly;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
> Passing NULL to %pNF is done in skb_gso_segment
> which could be dereferenced.
skb_gso_segment() should be fixed instead.
Maybe. Dereferencing NULL is bad form.
Michał Mirosław should fix that as it's his patch.
noinline_for_stack should be added anyway.
> On Tue, 2012-01-17 at 13:46 -0500, David Miller wrote:
>> From: Joe Perches <j...@perches.com>
>> Date: Tue, 17 Jan 2012 10:37:13 -0800
>> > Passing NULL to %pNF is done in skb_gso_segment
>> > which could be dereferenced.
>> skb_gso_segment() should be fixed instead.
>
> Maybe. Dereferencing NULL is bad form.
We don't check for NULL for IPV4 or IPV6 addresses, no reason
to treat this any differently.
Either do it for all %pX things, or none of them.
Because we don't pass NULL addresses.
> no reason
> to treat this any differently.
A NULL address is specifically passed here.
> Either do it for all %pX things, or none of them.
Maybe.
> On Tue, 2012-01-17 at 13:52 -0500, David Miller wrote:
>> From: Joe Perches <j...@perches.com>
>> no reason
>> to treat this any differently.
>
> A NULL address is specifically passed here.
And I said fix that skb_gso_whatever case, because it's wrong.
Isn't an additional copy of "struct printf_spec spec" on the stack
in function pointer() now?
Will do. This is in WARN() and easily fixed.
> noinline_for_stack should be added anyway.
Why? There are no local variables there and inlining this function would
actually save stack space as no stack frame would be created for the call.
Best Regards,
Micha� Miros�aw
If the function is inlined then gcc should know that original is not needed
after call and do no copy. Without inlining, gcc should too, optimize it
because it's a tail call.
We could read the generated assembly to be sure, of course.
Best Regards,
Micha� Miros�aw
At least for x86/gcc 4.6, it seems it doesn't make any difference.