keys: correctly check failed allocation for kmemdup
Subsystems (2)
PATCH 1/1 keys: correctly check failed allocation for kmemdup
kmemdup return value is saved in 'key->index_key.description', not 'key->descrption' and kmemdup can be failed in memory pressure. Therefore, key->index_key.description should be checked.
--- security/keys/key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/key.c +1 -1
@@ -278,7 +278,7 @@ struct key *key_alloc(struct key_type *type, const char *desc, key->index_key.desc_len = desclen; key->index_key.description =kmemdup (desc, desclen +1 ,GFP_KERNEL ); -if (!key->description) +if (!key->index_key.description) goto no_memory_3;atomic_set (&key->usage,1 );
Signature · 1 line
1.9.1
David Howells
maintainerQuoted 3 lines · Insu Yun
kmemdup return value is saved in '
key->index_key.description', not 'key->descrption' and kmemdup can be failed in memory pressure. Therefore,key->index_key.descriptionshould be checked.
The fields are unioned. It makes no difference.
David
A message that is not in the archive (sent off-list or not yet received): CAGoFzNe6VAQZd_jYb_rXSB=DhSW4bMm1vgtqwPadHbZLWav42w@mail.gmail.com
David Howells
maintainerQuoted 4 lines · Insu Yun
Thanks David. Then it is not a bug.
It's a pure question.
Why use different name for allocation and check?
For me, it is quite confusing.
Either I didn't notice at the time, or the shorter variant is the original.
If you want to give me a patch making it consistent, feel free.
David