From: Daniel Borkmann Date: Mon, 5 Jan 2015 23:27:45 +0000 (+0100) Subject: lib: memzero_explicit: add comment for its usage X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8155330aad477c5b1337895a6922df76817f0874;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git lib: memzero_explicit: add comment for its usage Lets improve the comment to add a note on when to use memzero_explicit() for those not digging through the git logs. We don't want people to pollute places with memzero_explicit() where it's not really necessary. Reference: https://lkml.org/lkml/2015/1/4/190 Suggested-by: Herbert Xu Signed-off-by: Daniel Borkmann Signed-off-by: Herbert Xu --- diff --git a/lib/string.c b/lib/string.c index 10063300b830..d984ec4fd3b7 100644 --- a/lib/string.c +++ b/lib/string.c @@ -604,6 +604,11 @@ EXPORT_SYMBOL(memset); * @s: Pointer to the start of the area. * @count: The size of the area. * + * Note: usually using memset() is just fine (!), but in cases + * where clearing out _local_ data at the end of a scope is + * necessary, memzero_explicit() should be used instead in + * order to prevent the compiler from optimising away zeroing. + * * memzero_explicit() doesn't need an arch-specific version as * it just invokes the one of memset() implicitly. */