All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] PATCH] ocfs2: fix warning 'ocfs2_orphan_del' uses dynamic stack allocation
@ 2015-01-26  1:26 Joseph Qi
  0 siblings, 0 replies; only message in thread
From: Joseph Qi @ 2015-01-26  1:26 UTC (permalink / raw)
  To: ocfs2-devel

In ocfs2_orphan_del it uses dynamic stack allocation for orphan entry
name. Fix it by using dynamic heap allocation.

Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Xuejiufei <xuejiufei@huawei.com>
---
 fs/ocfs2/namei.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 873b40a..a3aa6b5 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -2298,11 +2298,15 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
 {
 	int namelen = dio ? OCFS2_DIO_ORPHAN_PREFIX_LEN + OCFS2_ORPHAN_NAMELEN :
 			OCFS2_ORPHAN_NAMELEN;
-	char name[namelen + 1];
+	char *name;
 	struct ocfs2_dinode *orphan_fe;
 	int status = 0;
 	struct ocfs2_dir_lookup_result lookup = { NULL, };

+	name = kmalloc(namelen + 1, GFP_NOFS);
+	if (!name)
+		goto leave;
+
 	if (dio) {
 		status = snprintf(name, OCFS2_DIO_ORPHAN_PREFIX_LEN + 1, "%s",
 				OCFS2_DIO_ORPHAN_PREFIX);
@@ -2357,6 +2361,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
 	ocfs2_journal_dirty(handle, orphan_dir_bh);

 leave:
+	kfree(name);
 	ocfs2_free_dir_lookup_result(&lookup);

 	if (status)
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-26  1:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-26  1:26 [Ocfs2-devel] PATCH] ocfs2: fix warning 'ocfs2_orphan_del' uses dynamic stack allocation Joseph Qi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.