Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1247978 > unrolled thread

[PATCH] keys: correctly check failed allocation for kmemdup

Started byInsu Yun <wuninsu@gmail.com>
First post2015-10-15 18:30 +0200
Last post2015-10-15 21:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] keys: correctly check failed allocation for kmemdup Insu Yun <wuninsu@gmail.com> - 2015-10-15 18:30 +0200
    Re: [PATCH] keys: correctly check failed allocation for kmemdup David Howells <dhowells@redhat.com> - 2015-10-15 21:00 +0200
      Re: [PATCH] keys: correctly check failed allocation for kmemdup David Howells <dhowells@redhat.com> - 2015-10-15 21:50 +0200

#1247978 — [PATCH] keys: correctly check failed allocation for kmemdup

FromInsu Yun <wuninsu@gmail.com>
Date2015-10-15 18:30 +0200
Subject[PATCH] keys: correctly check failed allocation for kmemdup
Message-ID<qjTzI-3md-23@gated-at.bofh.it>
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.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 security/keys/key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/keys/key.c b/security/keys/key.c
index aee2ec5..c047846 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -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);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1248079

FromDavid Howells <dhowells@redhat.com>
Date2015-10-15 21:00 +0200
Message-ID<qjVUR-6LD-1@gated-at.bofh.it>
In reply to#1247978
Insu Yun <wuninsu@gmail.com> wrote:

> 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.

The fields are unioned.  It makes no difference.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1248113

FromDavid Howells <dhowells@redhat.com>
Date2015-10-15 21:50 +0200
Message-ID<qjWHg-7WB-23@gated-at.bofh.it>
In reply to#1248079
Insu Yun <wuninsu@gmail.com> wrote:

> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web